我正在使用表单身份验证来保护我的应用程序。
我在web.config中有以下内容:
<authentication mode="Forms">
<forms loginUrl="Login.aspx" name="ProjectName" defaultUrl="Users.aspx" slidingExpiration="true" timeout="2000" path="/" />
</authentication>
<location path="default.aspx">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
这允许我访问www.mysite.com/default.aspx,但我希望能够访问www.mysite.com,但当我尝试导航到该URL时,它会将我重定向到登录页面。
答案 0 :(得分:3)
<location path="/">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
答案 1 :(得分:1)
注意允许/拒绝元素:http://msdn.microsoft.com/en-us/library/8d82143t
<deny users="?" /> -- will deny access to all anonymous users, and redirect them to login page
<allow users="*" /> -- will allow access to all users, even anonymous, without redirect to login page.
和&lt; location&gt;:
<location path="/">
路径可能是:
"/" - is for root dir(and inner)
"file_or_dir" - restricts only the specified file or directory