Change Default “Default.aspx” to “Index.aspx” on Visual Studio 2010

后端 未结 3 1226
Happy的楠姐
Happy的楠姐 2020-12-18 13:42

Whenever I create a new Web Form on Visual Studio 2010, the default name is always \"Default.aspx\". This is a slight pain as I\'m having to change it to \"Index.aspx\" each

3条回答
  •  悲&欢浪女
    2020-12-18 14:41

    Although this does not cover all scenarios I have used the folowing code in the Gloabal.asax.cs to achieve this:

    public class Global : System.Web.HttpApplication
    {
        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            if (Request.Url.AbsolutePath.EndsWith("/"))
            {
                Server.Transfer(Request.Url.AbsolutePath + "index.aspx");
            }
        }
    }
    

    *You must remember to remove this code when deploying the code (or wrap in DEBUG statements)!

提交回复
热议问题