404 user errors for .aspx extensions

I am trying to redirect my web application to a custom 404 page. It works for all URLs except when they have the extension “.aspx”

The server is Windows Server 2008, and the following parameters I have in my web.config (for example, using google.com):

<customErrors defaultRedirect="http://www.google.com" mode="On" redirectMode="ResponseRedirect"></customErrors> <httpErrors errorMode="Custom"> <clear /> <remove statusCode="500" subStatusCode="-1" /> <remove statusCode="404" subStatusCode="-1" /> <error statusCode="404" prefixLanguageFilePath="" path="/404-Page/" responseMode="ExecuteURL" /> <error statusCode="500" prefixLanguageFilePath="" path="/404-Page/" responseMode="ExecuteURL" /> </httpErrors> 

Again, HTTP errors work for everything except the ".aspx" extensions

+4
source share
3 answers

To solve this problem, we had to create a module that captures any errors and transfers the user to my custom 404 page installed in the web.config file (under customErrors ). The module will add an event handler when the application receives an error message:

  public void Init(HttpApplication context) { context.Error += new EventHandler(FileNotFound_Error); } 

And the FileNoteFound_Error function does the redirection.

0
source

The customErrors element provides information about custom error messages for an ASP.NET application. Try adding the error child to the customErrors element for the specific HTTP error code you want to catch.

 <error statusCode="404" redirect="error404.htm"/> 
0
source

I had a similar problem in IIS6. I ended up working with it in Application_Error in global.asax. To make it work, I had to install a 404 user page on an aspx page that wasn’t (if I installed it on an existing aspx page, it will be absorbed by the internal error handling of EPiServer ...)

0
source

Source: https://habr.com/ru/post/1434717/


All Articles