为 ASP.NET (Visual Studio) 服务器配置设置默认页面 [英] Setting the default page for ASP.NET (Visual Studio) server configuration

查看:16
本文介绍了为 ASP.NET (Visual Studio) 服务器配置设置默认页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我构建和运行我的应用程序时,我在浏览器中得到一个目录列表(子文件夹也会出现),我必须点击 Index.aspx.这让我发疯.

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 making me crazy.

Visual Studio 2008ASP.NET 开发服务器 9.0.0.0

Visual Studio 2008 ASP.NET Development Server 9.0.0.0

推荐答案

内置网络服务器硬连线使用 Default.aspx 作为默认页面.

The built-in webserver is hardwired to use Default.aspx as the default page.

项目必须至少有一个空的 Default.aspx 文件来解决 Global.asax 的目录列表问题.

The project must have atleast an empty Default.aspx file to overcome the Directory Listing problem for Global.asax.

:)

一旦您添加了该空文件,所有请求都可以在一个位置处理.

Once you add that empty file all requests can be handled in one location.

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();
    }
}

这篇关于为 ASP.NET (Visual Studio) 服务器配置设置默认页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆