2012-06-13 34 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 
相關問題