如何在web.config中指定根(/)位置? [英] How to specify root (/) location in web.config?
问题描述
如何在web.config中指定根目录位置,以允许未经身份验证的用户访问它?
How does one specify root location in web.config to allow unauthenticated users access it?
默认情况下,根目录位置为.aspx,但是用户通常看不到default.aspx,而只是看到http://mysite.com/
.
The root location is served by default.aspx, but users normally don't see default.aspx, they just see http://mysite.com/
.
所以我添加了
<location path="~/default.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
如果用户点击mysite.com/default.aspx
,则可以使用,但是如果用户点击mysite.com/
,则仍可以-仍将其重定向到登录页面.
Which works if user hits mysite.com/default.aspx
, but if user hits mysite.com/
- he is still redirected to login page.
我尝试了<location path="~">
(无济于事),还尝试了<location path="~/">
,<location path="">
(站点完全失败),并且无法使其正常工作.
I've tried <location path="~">
(does not help) and also <location path="~/">
, <location path="">
(site fails completely) and could not make it work.
有什么想法吗?
推荐答案
尝试以下方法:
<system.web>
<urlMappings enabled="true">
<add url="~/" mappedUrl="~/default.aspx" />
</urlMappings>
<authorization>
<allow roles="admin"/>
<deny users="*" />
</authorization>
</system.web>
<location path="Default.aspx">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
</location>
这篇关于如何在web.config中指定根(/)位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!