Link to home
Start Free TrialLog in
Avatar of Abdu_Allah
Abdu_Allah

asked on

<customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> tag

Hi, I need to know the details of the errors that I get, I put <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
 but when the error appears the page redirects to mycustompage.htm but there is no error details appear, what should I do in mycustompage.htm page to show the details of the error?
ASKER CERTIFIED SOLUTION
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi
Make sure that, your web.config has this much only i.e., <customErrors mode="RemoteOnly"/>
Results of this is that if you know the scenario to reproduce, you will be able to see the complete error details when you run the app in local web server.  You will never get detailed error when you access remotely with this configuration.

Irrespctive of end user or service provider wants to see the complete error, then use <customError mode="On"/>

In case you don't want your customers to see the errors, then use Page_Error event on all webpages and try to redirect the user to the mycustompage.htm. example:
private void Page_Error(object sender, System.EventArgs e)
{
}
Hope this helps.
Thanks,
Ravi
In my above comment, i just forgot one snippet in Page_Error event on all web pages
Page_Error()
{
Exception errEx=Server.GetLastError();
string errmessage= errEx.Message
string stktrace= errEx.StackTrace
Server.ClearError(); // Make sure to clear the error after usage.
}
Avatar of Abdu_Allah
Abdu_Allah

ASKER

I guess I should write the error message errmessage before this statement: Server.ClearError();  
right?
 
You mean display the message in the page, yes
It does not show any error!
CB_Theromalia, how can I display the error message in the customerror.htm file When I use Application_Error event that found in global.asax file?!
Ok, if you want to show the error, then do a Response.Write(errEx.ToString()); before Server.ClearError();
Do that in global.asax file! this is not possible!
I have not said it to write that in global.asax, but in the page where you are catching the error, as said by sankar_ravi.
I get the following error although the system successfully redirect to my error.aspx page!
 
  Server Error in '/demo' Application. Runtime Error Description: 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.

Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".

<!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="Off"/> </system.web> </configuration>
Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.

<!-- Web.Config Configuration File --> <configuration> <system.web> <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/> </system.web> </configuration>
After turrning custom errors off as described above, I was able to see the FIPS was my issue. Some new 2008 security feature. Turned it off and rebooted. The website works.

Thanks