Unhandled exception was generated - asp.net

I have a website in which some pages are in ASP and some pages are in ASP.Net, But my problem is
when i execute it on my Local PC then it is working
But when I execute it from Our Server then Got Error " unhandled exception was generated during the execution of
the current web request. Information regarding the origin and location of the exception can be identified using
the exception stack trace below."
and This i come in only ASP.Net Pages.
Help me,
Thnx in Advance

This is often caused by lack of permissions to write to the file system on the web server, but it can really be caused by anything that differs from your development environment.
There is an error/exception available somewhere that will help you diagnose and correct the problem and you need to find that error. One place to look is the Windows Event Log. Another thing to check is how your web.config file sets the value for CustomErrors.
Are you seeing something like this at all?
http://www.codinghorror.com/blog/images/yellow-screen-of-death-large.png

Related

Custom Error mode set to "RemoteOnly", debugging locally still shows custom error page

In two of our ASP.Net Web Applications, in the Web.Config file, we've set the Custom Error redirect to our custom error page, and set the mode to "RemoteOnly" so that when we debug locally we see any unhandled exception message displayed on the "Yellow Screen of Death" - "YSoD".
This week, we discovered that when an unhandled exception is encountered, all of a sudden we're getting our custom error pages, instead of the exception details in the "YSoD".
This applies to only two, of the several applications we're running. I've searched high and low for a similar problem/solution, and haven't found much.
I'm trying to determine if this is an Application, IIS, or Visual Studio configuration problem. It just started happening, and there were no significant changes made to the server, etc., to potentially explain the problem. We have enabled IIS Failed Request Tracing, but I couldn't find anything associating this with our problem.
Given this information, what can cause this sudden change in behavior?
The back-end is a SQL Server database, using Windows Authentication, on an AWS VPC.

Security Exception while running an ASP.NET on deployment server

I am trying to run a WebAPI on a deployment server connected via a Remote Desktop link, but when I try to connect to the website via a browser, I get the error of:
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security.
Source Error:
An unhandled exception was generated during the execution of the current web request.
I can run and access the website fine when it is running from Visual Studio, its just when it is on the deployment server.
So far, I have tried:
Adding a <trust level="Full" /> element to web.config
Place the site in its own application pool in IIS (It already was).
The information in this article
Made changes to my code to see if it was the code itself which was causing the issue (I don't think it was, any request method such as POST and GET returned the same issue as above. I even tried other directories/URLs, I still got the error.)
Remove and re-publish the site several times.
Is there something which I am doing wrong which I'm not realising? Is there another way which I can solve this issue?
Any help would be appreciated.

Cause of "Could not load file or....Access is denied." IIS error?

The website I write code for encountered a problem today on a web server running IIS 7; it got a "Could not load file or assembly...Access is denied" error. This is the first time I've seen it, however, when the file in question was actually present in the bin folder.
I don't have direct access to the event log (that's our Networking dept's domain), so I asked them to send me the log of the errors over.
As a programmer, I don't see much useful in the log. The only part that I think might be of interest is the Request Information:
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\DefaultAppPool
I really don't see anything abnormal about any of it, but IIS isn't my forte. This DLL has been on the server for about 2 years now and this is the first time I've seen the error thrown.
Also, only one page on the site uses this file, but none of the pages throwing the error do. I'm guessing I was accessing cached versions of the other pages?
I'm just looking for possibilities that I can pass on for future reference, as the server isn't really my responsibility...of course, the website itself is, so if it breaks, it's all of our problem. Thanks for anything you can offer.
Runtime exceptions in asp.net applications generally do not show up in the error log. Ask your networking department for the warning log; it should contain the information you are looking for.

Handle unhandled exceptions in asp.net

How can we prevent page crash in asp.net? Is there any generic function or place like global.asax where we specify a file to redirect to when an unhanded exception occurs? (like we redirect to a specified page when 404 page not found exception occurs?
<customErrors> doesn't prevent your pages from "crashing". It just allows you to apologize to your users when the page does crash.
You should be examining the Application event log for messages from the source "ASP.NET <version>". These will include details of any exceptions your code has been generating and not handling. You need to fix these, as every one of these indicates that your users were not able to do what they came to your site to do.
You can do it in Global.asax or you can set up custom error pages in web.config.
ASP.NET Custom Error Pages
How can we prevent page crash in asp.net?
As Mal said, "If it crashes, you crashed it". The only way to "prevent" crashes is by carefully writing your code, testing, etc, as with any program.
To display a nice error page, check out the <customErrors> element in your web.config. MSDN docs here. Plenty of articles around if you google for 'customErrors'.

500 - Internal server error for ASPX page

I have created one test.aspx and my local machine it is working fine. Once I upload the same to server the page is not working. It's showing
500 - Internal server error. There is a problem with the resource you
are looking for, and it cannot be displayed.
It is impossible to help you without getting more info about the IIS configuration on your local machine and the server.
However, here's a quick stab of some things you should look at:
Check if Asp.net is installed on the server.
Make sure your app is targeting the proper .Net version that is on the server.
Check if all the assemblies your code is using are deployed correctly on the IIS server.
Add some exception handling and error logging to your code.
In particular, I'd venture to make a wild guess that your page is using some code that requires the IIS7 integrated pipeline and your server is either running IIS6 or is running IIS7 in classic mode. Though this is a stab in the dark and could turn out to be completely wrong. :-)
500 server errors are as useful as saying 'something broke'. They are the result of literally any exception you code throws plus anything else IIS croaks on. From your error msg, it sounds like an IIS config issue but it could still be your code. attaching a debugger to it would eliminate that possibility.
If you haven't looked at the server event log you can see if it registered anything.
There are a number of things that you can do to try to get a better, more specific exception. One way I try to diagnose them is to connect a remote debugger so I can see what's going on. If you have access to do so, I'd go that route.
You will need admin access to the server to install the Visual Studio remote debugging client (I'm assuming this is a .net app).
Another thing that can help are try/catch blocks and logging to a file or the event log--but have have to change your app most likely to implement that.
You have probably forgotten to upload the associated .dll. Have you tried right clicking on the project and using the publish feature?
If you are using IE, then you also need to turn off the "Show friendly error messages" option in Tools - Options - Advanced settings so that you get more details.
You may also need to change the web.config file so that error message details are shown, see the CustomErrors tag.

Resources