如何在ASP.NET中设置默认页面? [英] How to set the Default Page in ASP.NET?
问题描述
是否有任何节或代码可让我们在web.config
中设置默认页面?
Is there any section or code which allows us to set default page in web.config
?
例如,当人们第一次访问我的网站时,我希望他们看到的是CreateThing.aspx
而不是Default.aspx
.
For example, when people first visit my website, I want them to see CreateThing.aspx
rather than Default.aspx
.
我已经知道的解决方案:
-
将这行代码=>
Response.Redirect("CreateThings.aspx")
放入Default.aspx
Page_Load
事件中,但是此方法非常幼稚.
Put this line of code =>
Response.Redirect("CreateThings.aspx")
inDefault.aspx
Page_Load
event but this method is really naive.
我们可以使用IIS(默认页面配置),但是我想在我的ASP.NET应用程序上做同样的事情.
We can use IIS (default page configuration,) but I wanna do the same thing over on my ASP.NET application.
这可能是目前的另一种解决方案:
This could be another solution for now:
<defaultDocument>
<files>
<clear />
<add value="Default.aspx" />
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="index.html" />
<add value="iisstart.htm" />
</files>
</defaultDocument>
推荐答案
如果使用IIS 7或IIS 7.5,则可以使用
If using IIS 7 or IIS 7.5 you can use
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="CreateThing.aspx" />
</files>
</defaultDocument>
</system.webServer>
https://docs.microsoft.com/zh-cn/iis/configuration/system.webServer/defaultDocument/
这篇关于如何在ASP.NET中设置默认页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!