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)
{
base.OnLoad(e);
this.Response.Redirect("~/default.aspx", false);
this.Response.Status = "301 Moved Permanently";
this.Response.StatusCode = 301;
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>
</div>
</form>
</body>
</html>
Last modified by Mohit @ 4/6/2025 10:05:32 PM