Just a simple redirect ASPX page
Published Aug 23 2019 08:45 AM 7,759 Views
Microsoft

You need to set a very simple redirect, from a specific location on your IIS web site or application, to a new URL? Then place this very simple default.aspx page at that location; in most of the cases, it works like a charm.

 

<%@ Page Language="C#"%>
<%
    Response.RedirectLocation = "http://new.location.net/optional/path";
    Response.StatusCode = 301;   //   301 = Moved Permanently   |   302 = Object moved   |   307 = Temporary redirect
%>

 

This is aimed at those of us too lazy to enable and use the HTTP Redirection feature of IIS. That would work with much better performance, and would cover some additional functionality, and doesn't need the .NET managed pipeline... But sometimes lazy is good :)

For those in need of complex redirects, the optional UrlRewrite module is THE solution, but you'll need to install and learn creating redirect rules.

Best of luck to all!

3 Comments
Version history
Last update:
‎Aug 23 2019 08:45 AM
Updated by: