2012-06-13 26 views
0

我使用表单身份验证来保护我的应用程序。表单身份验证,允许/被所有人看到

我已在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时,它会将我重定向到登录页面。

回答

3
<location path="/"> 
<system.web> 
    <authorization> 
    <allow users="*"/> 
    </authorization> 
</system.web> 
</location> 
+0

我得到一个500当我补充这个给web.config – MillinMo

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. 

而且<位置>:

<location path="/"> 

凡路径可能是:

"/" - is for root dir(and inner) 
"file_or_dir" - restricts only the specified file or directory 
相关问题