0

Please find attached the error I am getting while trying to display a custom error message. My application ASP.Net 4 and uses IIS 7.5. HEre is my code in web.config.

</httpErrors>

enter image description here

bp581
  • 859
  • 1
  • 16
  • 47

1 Answers1

0

You should have your this under system.web

<system.web>
    <customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/ErrorPages/WebError.aspx"/>

And this under system.webServer (one of a few options)

<system.webServer>
    <httpErrors existingResponse="PassThrough"/>
smoore4
  • 4,520
  • 3
  • 36
  • 55
  • Now I get Server Error as Server Error in '/' Application. Runtime Error Description: An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated. – bp581 Apr 17 '14 at 17:52
  • Set customErrors mode="RemoteOnly" so you can get more detail. Txs. – smoore4 Apr 17 '14 at 18:44
  • I did it but does not help. All I want to accomplish is redirect the users when unexpected error happens in the application. Can anyone tell me how to accomplish this ?.Thx – bp581 Apr 17 '14 at 20:08
  • Looks like this simple code Works when run it in VisualStudio. But If I publish it to IIS 7.5 and test it ..the code does not display the customer error. ANy idea why ? – bp581 Apr 17 '14 at 20:32
  • Can you reach the page directly after publishing? http://mypublishedsvr/myapp/ErrorPages/WebError.aspx – smoore4 Apr 18 '14 at 06:02
  • No I cannot get to /ErrorPages/WebError.aspx directly. Also I saved a Test.html in the same path and can access the html path at /Errorpages/Test.html. What could be going wrong ?. – bp581 Apr 18 '14 at 23:59