Is it possible to enable remote errors for a single aspx page?
I have a page that is blowing up and I am getting this error:
An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine.
In this particular case I am unable to remote into the server开发者_Python百科. I am however able to access the wwwroot folder where pages are being hosted. The page I am trying to upload works on my test server but when I put it into production it is throwing the error. I suspect due to a missing namespace.
Is there anyway to enable remote errors for this one page or otherwise capture the exception detail? It is being thrown before Page_Load()
If you have access to the Event Log of the server, this is the place where unhandled exception details are usually written by ASP.NET.
Another possibility is to enable temporarily exception details in web.config to be shown remotely by setting:
<customErrors mode="Off" />
This will display the exception stacktrace instead of a YSOD so that you know what the problem is.
And yet another possibility is to subscribe to the Appliaction_Error method in Global.asax and log yourself the exception being thrown. By the way that's something that you should do anyways.
You may also checkout ELMAH.
Of course all this will be futile if your application is not configured properly in IIS (like for example errors in your web.config, incorrect ASP.NET version in the virtual directory, .NET Framework not installed on the remote server, ...). In this case you probably need access to the server.
Enabling remote errors is a very bad idea. Proper error handling is critical to prevent unintentional information disclosure, which gives attackers helpful information. It's worth reading up on.
There's plenty of guidance here: http://msdn.microsoft.com/en-us/library/w16865z6.aspx
There are some errors, however, that you can't code around. Loading an ASP.NET 4.0 website to a server that does not have the .NET Framework 4.0 installed, for example. Your error handling won't work because the code just won't run. If you suspect this is the case, you may need to check with the administrator to ensure that the right version is set up and IIS is configured to run your application using the correct target framework.
If you temporarily want's to enable remote errors for one .aspx page just add "Debug=true" to the page like this <%@ Page Language="C#" Debug="true" .... %>
精彩评论