Using the Login control in .NET

When I first started out programming in .NET, the first obstacle I faced was setting up the database for the login control. So here it is, these steps might help you solve that problem -

  1. Run C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe

  2. Follow the steps and create the ASPNETDB.mdf in the location of your choice. (I personally prefer dumping the tables in my application’s database itself so that I can have a relation between the generated tables and my other tables.) LoginControlSetup
  3. After you are done setting that up, open the web.config file and add the following in the ConnectionStrings section:
<connectionstrings>

 <remove name="LocalSqlServer"/>

 <add connectionString="Data Source=[ServerName];Initial Catalog=[Database];Integrated Security=True" providerName="System.Data.SqlClient" name="LocalSqlServer"/>

 <add connectionString="Data Source=[ServerName];Initial Catalog=[Database];Integrated Security=True;Pooling=False" providerName="System.Data.SqlClient" name="ConnectionString"/>

</connectionstrings>

Make sure in both the connection strings the server/database name matches with the location you selected in step 2.

That should do it!

If you have any questions or comments, please post them below. If you liked this post, you can share it with your followers or follow me on Twitter!