2009-12-08 25 views
6

この仕様はルートweb.configファイルで正しいですか?保護されたフォルダに子web.configを使用していません。フォーム認証web.configの設定

また、ルートweb.configファイルでのsystem.webためすると別の仕様
<system.web> 
    <authentication mode="Forms"> 
    <forms name=".ASPXAUTH" loginUrl=""> 
    </forms> 
    </authentication> 
</system.web> 

<location path="to protected folder"> 
    <system.web> 
    <authorization> 
     <deny users="?"/> 
    </authorization> 
    </system.web> 

答えて

4

あなたは、次の要素を設定web.configファイルをする必要があります。

<configuration> 
    <system.web> 
     <authentication mode="Forms"> 
      <forms name="SiteName" path="/" loginUrl="~/Login.aspx" protection="All" timeout="30" /> 
     </authentication> 
    </system.web> 
</configuration> 

フォルダを保護するには、匿名アクセスを拒否するweb.configを配置します。

<configuration> 
    <system.web> 
    <!-- Place in a sub folder that you want to protect using Forms Authentication --> 
    <authorization> 
     <deny users="?" /> 
    </authorization> 
    </system.web> 
</configuration> 
2

Web.configファイルがchieldフォルダにカスケード接続されて、あなたの仮定が正しいか、使用のログインURL

<authentication mode="Forms"> 
<forms defaultUrl="~/Step1.aspx" loginUrl="~/Signup.aspx" slidingExpiration="true" timeout="1000"> 
    <credentials passwordFormat="Clear"> 
    <user name="admin" password="123.admin"/> 
    </credentials> 
</forms> 
</authentication> 
<authorization> 
    <allow users="admin" /> 
    <deny users="?"/> 
</authorization> 
0

のsystem.webタグの下に構成タグと認証要素の下のconnectionStrings要素を追加します。ここで

<connectionStrings> 
<add name="cs"connectionString="Data source=server_name; Initial Catalog=database_name; User Id=user_id; Password=user_password" providerName="System.Data.SqlClient" /> 
</connectionStrings> 

<authentication mode="Forms"> 
    <forms loginUrl="~/Home/LogOn"defaultUrl="~/Home/Home"timeout="2880" /> 
</authentication> 

はここで働いExample

です