Web.config forms authentication installed

Is this specification correct in the root web.config file? I did not use the child web.config file in the protected folder.

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

Then another specification for system.web is also located in the root web.config:

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

+8
source share
3 answers

You must configure the web.config file with the following elements.

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

You can protect folders by placing a web.config file that prohibits anonymous access.

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

The Web.config file is located in the child folders, your guess is correct, use the login 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> 
+2
source share

Add the connectionStrings element in the configuration tag and the authentication element in the system.web tag.

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

Here is a working example here

0
source share

All Articles