Dan*_*ams 27 asp.net configuration visual-studio-2008
当我构建并运行我的应用程序时,我在浏览器中获得了一个目录列表(对于子文件夹也是如此),我必须单击Index.aspx.这让我发疯了.
Visual Studio 2008 ASP.NET开发服务器9.0.0.0
Jam*_*aro 39
右键单击要用作默认页面的网页,并在从Visual Studio运行Web应用程序时选择"设置为起始页",它将打开所选页面.
zpr*_*oxy 20
内置的Web服务器硬连线使用Default.aspx作为默认页面.
该项目必须至少有一个空Default.aspx文件来克服目录列表问题Global.asax.
:)
添加该空文件后,可以在一个位置处理所有请求.
public class Global : System.Web.HttpApplication
{
protected void Application_BeginRequest(object sender, EventArgs e)
{
this.Response.Write("hi@ " + this.Request.Path + "?" + this.Request.QueryString);
this.Response.StatusCode = 200;
this.Response.ContentType = "text/plain";
this.Response.End();
}
}
Run Code Online (Sandbox Code Playgroud)
Phi*_*ert 11
转到项目的属性页面,选择"Web"选项卡并在顶部(在"开始操作"部分中),在"特定页面"框中输入页面名称.在您的情况下index.aspx
类似于上面的zproxy的回答,我使用了Gloabal.asax.cs中的下面的代码来实现这个目的:
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");
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
108638 次 |
| 最近记录: |