R – Custom Errors for “App” folders? (ASP.NET)

asp.neterror handlingiisweb.config

Where can I setup custom errors for directories in my application such as App_Code, App_Browsers, etc.? I already have customErrors configured in the web.config and that works as expected. For example,

http://www.mysite.com/bla.aspx > redirects to 404 page

but

http://www.mysite.com/App_Code/ > displays "The system cannot find the file specified."

There's no physical App_Code directory for my site. Is this something that I can change in IIS?

Best Answer

You are trying to server content from an Protected Folder... ??

I think you might need to allow access to these folders to get the nice errors you are looking for...

http://www.webdavsystem.com/server/documentation/hosting_iis_asp_net/protected_folders

That being said... there is a reason these folders are protected.

I would never put anything i needed IIS to serve in protected folders.

But there are always reasons to do do something? i have broke a few rules in my short lifespan :)

UPDATE:

Found this when i tried this locally: http://support.microsoft.com/kb/942047/

Looks like those reserved directories throw special 404's you might be able to get IIS to Target the 404.8 type... with out opening up serving to those directories