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>
As Jon said, the <authorization> node should not be a child of the <customErrors> node.