Redirect old .asp or any non aspx pages using 404


Add this to the System Webserver section in the web.config file to handle any non .aspx pages


<system.webServer>

<httpErrors errorMode="Custom">

<remove statusCode="404" subStatusCode="-1" />

<error path="/" prefixLanguageFilePath="" responseMode="ExecuteURL" statusCode="404" />

</httpErrors>

</system.webServer>


Just keep in mind that the Error Path section can be set to whatever file you require the error to be redirected to.

Example:
error path="/"
Or
error path="/errorpage.htm"
Or
error path="/404.aspx"

etc etc.
  • Email, SSL
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Cross-Site Scripting in ASP.NET

Cross-Site Scripting in ASP.NET Cross-site scripting attacks exploit vulnerabilities in Web page...

How to change DOT NET Version (Site level)

Login to your control panel at http://control.apexhost.net.au Please note: Ensure you set your...

301 redirect using global.asax.cs

Below is code to do 301 redirect using the global.asax.cs file.   ...

Automatically switching between HTTP and HTTPS protocols without hard-coding absolute URLs

An article on automatically switching between HTTP and HTTPS protocols without hard-coding...

How to use the session state server (Sessions issues)

If you are having problems loosing sessions please use the session state server. (ASP.NET only)...