asp.net应用程序默认文件Index.aspx

b0x*_*0rz 8 c# asp.net settings web-applications

我怎么能这样做,当我去(例如)http://localhost:60288/它没有显示我的目录列表,而是打开Index.aspx页面?这适用http://localhost:60288/Index.aspx但我不希望Index.aspx每次都显示.

我还需要http://localhost:60288/?a=1http://localhost:60288/Index.aspx?a=1没有Index.aspx显示那样工作的链接.

当我在visual studio中创建一个网站项目时,这曾经工作,但现在我正在使用应用程序项目.我怎么设置它?

我希望/需要这个适用于所有子文件夹,例如http://localhost:60288/SubFolder/应该像链接到的那样工作http://localhost:60288/SubFolder/Index.aspx

日Thnx

编辑仍然没有管理它

Chr*_*ris 12

Cassini(Visual Studio使用的内置Web服务器)不允许您配置在URL中未指定文件名时使用的默认文档.正如您所发现的那样,"设置为起始页"选项不是一回事,因为它只会影响您在运行项目时首次打开哪个页面,并且不会影响后续页面加载.

但是,Cassini确实一个默认文档列表 - 它只是不可配置,列表只包含"default.aspx"和"default.htm".在Cassini中实现所需功能的唯一方法是将所有"index.aspx"文件重命名为"default.aspx".


cla*_*ass 9

我这样做的最简单方法是使用映射.在Web.config中,插入以下内容:

<configuration>                                                                  
    <system.web>                                                                 
        <compilation debug="true" targetFramework="4.0" />                       
        <urlMappings enabled="true">                                             
            <add url="~/" mappedUrl="~/index.aspx" />                
            <add url="~/default.aspx" mappedUrl="~/index.aspx" />                
        </urlMappings>                                                           
    </system.web>                                                                
</configuration>            
Run Code Online (Sandbox Code Playgroud)