How to set the Default Page in ASP.NET? How to set the Default Page in ASP.NET? asp.net asp.net

How to set the Default Page in ASP.NET?


If using IIS 7 or IIS 7.5 you can use

<system.webServer>    <defaultDocument>        <files>            <clear />            <add value="CreateThing.aspx" />        </files>    </defaultDocument></system.webServer>

https://docs.microsoft.com/en-us/iis/configuration/system.webServer/defaultDocument/


Tip #84: Did you know… How to set a Start page for your Web Site in Visual Web Developer?

Simply right click on the page you want to be the start page and say "set as start page".

As noted in the comment below by Adam Tuliper - MSFT, this only works for debugging, not deployment.


Map default.aspx as HttpHandler route and redirect to CreateThings.aspx from within the HttpHandler.

<add verb="GET" path="default.aspx" type="RedirectHandler"/>

Make sure Default.aspx does not exists physically at your application root. If it exists physically the HttpHandler will not be given any chance to execute. Physical file overrides HttpHandler mapping.

Moreover you can re-use this for pages other than default.aspx.

<add verb="GET" path="index.aspx" type="RedirectHandler"/>

//RedirectHandler.cs in your App_Code

using System;using System.Collections.Generic;using System.Linq;using System.Web;/// <summary>/// Summary description for RedirectHandler/// </summary>public class RedirectHandler : IHttpHandler{    public RedirectHandler()    {        //        // TODO: Add constructor logic here        //    }    #region IHttpHandler Members    public bool IsReusable    {        get { return true; }    }    public void ProcessRequest(HttpContext context)    {        context.Response.Redirect("CreateThings.aspx");        context.Response.End();    }    #endregion}