I am trying to write a simple authentication. I'm also trying to make this quick and learn about the forms authentication via web.config.

So i have my authentication working if I hard code my 'user name' and 'password' into C# code and do a simple conditional.

However, I get en error message 'Unrecognized element 'authentication'.

Line 2: <system.web> Line 3: <customErrors mode="off"> Line 4: <authentication mode="Forms"> Line 5: <forms name=".C#FEWD" Line 6: loginUrl="/schools/admin/login/index.aspx" 

My web.config file looks like this:

<configuration> <system.web> <customErrors mode="off"> <authentication mode="Forms"> <forms name=".C#FEWD" loginUrl="/schools/admin/login/index.aspx" protection="All" timeout="60"> <credentials passwordFormat="Clear"> <user name="schools" password="magic" /> </credentials> </forms> </authentication> <authorization> <deny users="?" /> </authorization> </customErrors> </system.web> </configuration> 

2 Answers

Its probably just that you're missing the node terminator from your customErrors setting:

<customErrors mode="off"/> 

More following comment:

Your complete config should be:

<configuration> <system.web> <customErrors mode="off" /> <authentication mode="Forms"> <forms name=".C#FEWD" loginUrl="/schools/admin/login/index.aspx" protection="All" timeout="60"> <credentials passwordFormat="Clear"> <user name="schools" password="magic" /> </credentials> </forms> </authentication> <authorization> <deny users="?" /> </authorization> </system.web> </configuration> 
3

As Jon said, the <authorization> node should not be a child of the <customErrors> node.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.