代码之家  ›  专栏  ›  技术社区  ›  b0x0rz

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

  •  8
  • b0x0rz  · 技术社区  · 16 年前

    当我去(例如)时,我怎样才能做到这一点 http://localhost:60288/ 它不显示目录列表,而是打开 Index.aspx 页这与 http://localhost:60288/Index.aspx Index.aspx 每次都会显示。

    我也需要像这样的链接 http://localhost:60288/?a=1 http://localhost:60288/Index.aspx?a=1 没有 Index.aspx 展示。

    当我在VisualStudio中创建一个网站项目时,这一点曾经有效,但现在我使用的是应用程序项目。我如何设置这个?

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

    thnx

    编辑

    5 回复  |  直到 16 年前
        1
  •  13
  •   Chris    16 年前

    Cassini(Visual Studio使用的内置Web服务器)不允许您配置在URL中未指定文件名时使用的默认文档。正如您所发现的,“设置为起始页”选项与此不同,因为它只影响运行项目时第一次打开的页面,而不影响后续页面加载。

    默认文档的列表-它只是不可配置,并且该列表只包含“Default.aspx”和“Default.htm”。在Cassini中实现所需的唯一方法是将所有“index.aspx”文件重命名为“default.aspx”。

        2
  •  9
  •   class    13 年前

    <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>            
    
        3
  •  2
  •   Chris    16 年前

    进入IIS管理器(在控制面板-管理工具中)

    右键单击-默认网站上的属性

    文档选项卡-确保勾选了“启用默认文档”,并且index.aspx位于默认文档列表中,最好位于顶部。

    让我知道你怎么样了。

        4
  •  0
  •   Shyju    16 年前

    您可以删除或重命名index.aspx,以便在运行时显示目录列表,除非您将另一页设置为起始页。

    第二件事,你可以使用ASP.NETURL屏蔽特性

        5
  •  0
  •   to StackOverflow    16 年前

    您可以使用IIS管理器为站点/应用程序设置默认文档。

    Cassini(集成在Visual Studio中的开发web服务器)不支持更改默认文档。