在Asp.net设置默认页 [英] Set Default Page in Asp.net
问题描述
是否有任何部分或code,它允许我们设置默认页面的web.config
?
例如,当人们第一次访问我的网站,我希望他们看到 CreateThing.aspx
,而不是 Default.aspx的
。
的解决方案,我知道:
-
将这个行code =>
的Response.Redirect(CreateThings.aspx)
在Default.aspx的
的Page_Load
事件,但这种方法真的很幼稚。 -
我们可以使用
IIS
(默认页面配置),但我想要做了Asp.NET应用同样的事情。
如果你知道一个更好的解决方案,请让我知道。
在此先感谢。
的 PS:为什么我问的的Web.Config
是我相信的原因的Web.Config
将帮助我们通过这一点。的
修改:
我只是想知道微软的.NET团队如何忘记这样一个简单的事情:)
编辑:
这可能是现在另一种解决方案:
< defaultDocument>
<&文件GT;
<清/>
<增加价值=Default.aspx的/>
<增加价值=Default.htm的/>
<增加价值=Default.asp的/>
<增加价值=index.htm的/>
<增加价值=的index.html/>
<增加价值=iisstart.htm/>
< /文件>
< / defaultDocument>
如果使用IIS 7或IIS 7.5,你可以用
< system.webServer>
< defaultDocument>
<&文件GT;
<清/>
<增加价值=CreateThing.aspx/>
< /文件>
< / defaultDocument>
< /system.webServer>
<一个href=\"http://www.iis.net/ConfigReference/system.webServer/defaultDocument\">http://www.iis.net/ConfigReference/system.webServer/defaultDocument
Is there any section or code which allows us to set default page in web.config
?
For example, when people first visit my website, I want them to see CreateThing.aspx
rather than Default.aspx
.
The solutions I know :
Put this line of code =>
Response.Redirect("CreateThings.aspx")
inDefault.aspx
Page_Load
event but this method is really naive.We can use
IIS
(default page configuration) but I wanna do the same thing over Asp.NET application.
If you know a better solution, please let me know.
Thanks in advance.
P.S : The reason why I am asking about Web.Config
is I believe Web.Config
would help us through this.
Edit: I am just wondering how Microsoft .NET team forgot such a simple thing :)
Edit :
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>
If using IIS 7 or IIS 7.5 you can use
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="CreateThing.aspx" />
</files>
</defaultDocument>
</system.webServer>
http://www.iis.net/ConfigReference/system.webServer/defaultDocument
这篇关于在Asp.net设置默认页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!