如何在IIS7中设置应用程序的默认页面?

Den*_*ail 33 iis-7

我将我的Web应用程序部署到IIS7,一切正常.但是,我希望它自动转到www.xxxxxx.com/views/root/default.aspx,而不是输入我的真实起始页面的网址.

我该怎么做呢?

小智 41

只需转到web.config文件并添加以下内容即可

<system.webServer>
    <defaultDocument>
      <files>
        <clear />
        <add value="Path of your Page" />
      </files>
    </defaultDocument>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)


小智 20

  1. 在IIS管理器上,在"站点"树中选择您的页面.
  2. 双击配置编辑器.
  3. 在下拉列表中选择system.webServer/defaultDocument.
  4. 将"default.aspx"更改为文档名称.


Zer*_*ity 5

卡兰(Karan)发布了答案,但这对我不起作用。因此,我正在发布对我有用的内容。如果那没有用,那么用户可以尝试一下

<configuration> 
    <system.webServer> 
        <defaultDocument enabled="true"> 
            <files> 
                <add value="myFile.aspx" /> 
            </files> 
        </defaultDocument> 
    </system.webServer>
</configuration> 
Run Code Online (Sandbox Code Playgroud)


pra*_*ant 1

如果你想做类似的事情,用户输入url“www.xxxxxx.com/views/root/”并显示默认页面,那么我想你必须在IIS中设置default/home/welcome页面属性。但是,如果用户只是输入“www.xxxxxx.com”,而您仍然想转发到您的网址,那么您需要在默认页面中编写一行代码来转发到您想要的网址。此默认页面应位于应用程序的根目录中,因此 www.xxxxx.com 将加载 www.xxxx.com/index.html ,这会将用户重定向到您想要的网址