Asp.NET default.aspx page to redirect to home
The following illustrates an ASP.Net page that will redirect the user to another page with a '301 Moved Permanently' status. This is useful for web application folders that have pages under them, but a 'default' page in that folder is not desired.
<%@ Page Language="C#" AutoEventWireup="true" %> <!DOCTYPE html> <script runat="server"> protected override void OnLoad(EventArgs e) { // call the method on the base class base.OnLoad(e); // set the page to where the user should be redirected. this.Response.Redirect("~/default.aspx", false); // set the status text this.Response.Status = "301 Moved Permanently"; // set the status code this.Response.StatusCode = 301; // end the response this.Response.End(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <!-- <%-- No need to put anything in here. --%> --> </div> </form> </body> </html>