Click here to Skip to main content
15,881,876 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hallo,

I have added a custom error page for my vb.net application. The section in the web.config-file looks like this:
XML
<customErrors mode="On" defaultRedirect="/error/error.aspx">
      <error statusCode="404" redirect="/error/error404.aspx" />
    </customErrors>

If I test this locally using visual studio, it works fine. However, if i deploy the project on the web-server it only works partially. If I type in a web address, that does not exist, I am redirected to the error page. However, when I try to open a pdf-document via the web application that I do not have access to (and that physically does not exist in the sub-folder I access) I get the standard 404-page, not my custom page.
Are there any settings on the web-server or any other sections of the web.config file I have to modify?

Thanks in advance
Posted
Updated 2-Jan-12 23:27pm
v2

By default, the IIS web server processes requests for static content like images and HTML files without invoking the ASP.NET engine. Consequently, if the user requests a non-existent file they will get back IIS's default 404 error message rather than ASP.NET's configured error page.

A PDF download request would be taken care of by IIS and not ASP.Net handlers.
As a result, you don't see your 404 custom error handler page.

Have a look at http://www.asp.net/web-forms/tutorials/deployment/displaying-a-custom-error-page-cs[^] for more details.
 
Share this answer
 
v2
Comments
Monjurul Habib 4-Jan-12 14:47pm    
5!
Look at the IIS configuration how the error pages are configured.

More details at: http://www.dotnetscraps.com/dotnetscraps/post/Did-you-know-Enable-Custom-Error-in-IIS-7-75.aspx[^]
 
Share this answer
 
Hi,

Please refer Custom error in IIS

hope this will help you,


thanks
-amit
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900