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.
  • 5 Users Found This Useful
Was this answer helpful?

Related Articles

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 create a Virtual Directory

How to create a Virtual Directory (Application for Asp.net) If you need asp.net to...

Web.config file does not run

If your web.cofig file doesnt run (Even though the error keeps telling you to modify the...

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)...

Cross-Site Scripting in ASP.NET

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