Not logged in - Login

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

        // 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

<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        <%-- No need to put anything in here. --%>