aherlambang
aherlambang

Reputation: 14418

forms authentication

Ok so I am using forms authentication in my web site and I defined this in my config. Therefore I have an ASPNETDB.MDF. So do I need to have a database called ASPNETDB.MDF in my web host? If that is the case then how do I connect this so that my site uses this to verify users? I am sorry this seems to be like a very noob question

Upvotes: 0

Views: 260

Answers (2)

Michael Grassman
Michael Grassman

Reputation: 1935

Place the ASPNETDB.MDF in your App_Data folder.

The connection string to use is <add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf" />

When you hook this connection string to your membership provide the authentication will use your ASPNETDB.MDF file.

-------------------Try the following-----------------

Sorry place a above the connection string above you should be able to change the name of the connection string. You will also need to change this in your membership element.

    <connectionStrings>
<clear />
    <add name="NewConnectionString" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf" providerName="System.Data.SqlClient" />
    </connectionStrings>

<membership>
        <providers>
            <clear/>
            <add name="AspNetSqlMembershipProvider"
                connectionStringName="NewConnectionString"
                ...                     
                type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
        </providers>
    </membership>

Upvotes: 1

James Westgate
James Westgate

Reputation: 11464

You dont have to use a database to use forms authentication, you can define the entries in the web.config file if you like. It depends on the MembershipProvider that you are using.

Have a look here for an example

Upvotes: 0

Related Questions