Forms authentication: how do you store username password in web.config?

Posted by Nick G on Stack Overflow See other posts from Stack Overflow or by Nick G
Published on 2012-11-20T10:44:45Z Indexed on 2012/11/20 11:02 UTC
Read the original article Hit count: 164

I'm used to using Forms Authentication with a database, but I'm writing a little internal utility and the app doesn't have a database so I want to store the username and password in web.config. However for some reason, forms authentication is still trying to access SQL Server and I can't see how to stop it doing this and pick up the credentials from web.config. What am I doing wrong? I just get the error "Failed to generate a user instance of SQL Server due to a failure in impersonating the client. The connection will be closed."

Here are the relevant sections of my web.config:

<configuration>
    <system.web>
        <authentication mode="Forms">
            <forms loginUrl="~/Login.aspx" timeout="60" name=".LoginCookie" path="/"  >
                <credentials passwordFormat="Clear">
                    <user name="user1" password="[pass]" />
                    <user name="user2" password="[pass]" />
                </credentials>
            </forms>
        </authentication>
        <authorization>
            <deny users="?" />
        </authorization>
    </system.web>
</configuration>

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about forms-authentication