Configure db used for ASP.Net authentication

I want to use authentication on my asp.net mvc site.

Can I use an existing sql db (on a remote server) for it? How to configure a site to use this db for authentication? What tables do I need / use for authentication?

+5
source share
2 answers

You can. Check the program settings aspnet_regsql.exein the Windows \ Microsoft.NET \ Framework \ v2.xxx folder, especially sqlexportonly.

After creating the necessary tables, you can configure: create a connection string in the web.config file, and then configure MemberShipProvider to use this connection string:

  <connectionStrings>
    <add name="MyLocalSQLServer" connectionString="Initial Catalog=aspnetdb;data source=servername;uid=whatever;pwd=whatever;"/>
  </connectionStrings>

<authentication mode="Forms">
  <forms name="SqlAuthCookie" timeout="10" loginUrl="Login.aspx"/>
</authentication>
<authorization>
  <deny users="?"/>
  <allow users="*"/>
</authorization>
<membership defaultProvider="MySqlMembershipProvider">
  <providers>
    <clear/>
    <add name="MySqlMembershipProvider" connectionStringName="MyLocalSQLServer" applicationName="MyAppName" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
  </providers>
</membership>

Ps: .

+4

- windows aspnet_regsql.exe.

c:\windows\microsoft.net\framework\v2.0.50727.

aspnet_regsql.exe, , - .

+1

All Articles