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

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

问题描述

当我生成和运行我的应用程序我得到一个目录列表浏览器(也恰好子文件夹),我有点击Index.aspx的。它让我疯了。

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


解决方案

  

内置的网络服务器被硬连接到使用的Default.aspx作为默认页面。


该项目必须有ATLEAST空 Default.aspx的文件克服目录列表问题为的Global.asax

:)

一旦你添加一个空文件的所有请求可以在一个位置进行处理。

 公共类全球:System.Web.HttpApplication
{
    保护无效的Application_BeginRequest(对象发件人,EventArgs的发送)
    {
        this.Response.Write(?嗨@+ this.Request.Path + + this.Request.QueryString);
        this.Response.Status code = 200;
        this.Response.ContentType =text / plain的;        this.Response.End();
    }
}

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 2008 ASP.NET Development Server 9.0.0.0

解决方案

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

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天全站免登陆