2009-12-08 5 views
6

Cette spécification est-elle correcte dans le fichier racine web.config? Je n'ai pas utilisé un web.config enfant dans le dossier protégé.Configuration de l'authentification par les formulaires web.config

<system.web> 
    <authentication mode="Forms"> 
    <forms name=".ASPXAUTH" loginUrl=""> 
    </forms> 
    </authentication> 
</system.web> 

Puis une autre spécification pour system.web aussi dans web.config racine:

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

Répondre

4

Vous devez configurer le web.config avec les éléments suivants.

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

Vous pouvez protéger les dossiers en plaçant un web.config qui refuse l'accès anonyme.

<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 dans des dossiers est en cascade chield, votre hypothèse est correcte, l'utilisation URL de connexion

<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

Ajouter un élément connectionStrings sous étiquette de configuration et de l'élément d'authentification sous étiquette system.web.

<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> 

est ici un groupe de travail Example ici

Questions connexes