Setting the default page for ASP.NET (Visual Studio) server configuration

前端 未结 8 776
北荒
北荒 2020-12-05 13:38

When I build and run my application I get a directory listing in the browser (also happens for sub folders), and I have to click on Index.aspx. It\'s makin

8条回答
  •  萌比男神i
    2020-12-05 14:07

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

提交回复
热议问题