使用SQL Server数据库进行登录控制,而不是默认的ASPNETDB.mdf数据库

本文关键字:数据库 默认 ASPNETDB mdf 控制 Server SQL 使用 登录 | 更新日期: 2023-09-27 18:19:19

我试图使用SQL Server数据库,而不是默认数据库(ASPNETDB.mdf)的ASP登录凭据。. NET web应用程序,我正在建设。我找到并运行了aspnet_regsql.exe,它用正确的表填充了数据库,但是我如何改变所有默认登录控件的位置?在做了研究之后,我觉得我可能必须对App_Data文件夹或web.config文件做些什么,但我不知道该怎么做。

使用SQL Server数据库进行登录控制,而不是默认的ASPNETDB.mdf数据库

只需更改web配置中成员部分的连接属性字符串,以使用数据库连接字符串部分中的任何数据库连接,如:

<connectionStrings>
    <add name="membershipConnectionString" connectionString="Data Source=ALGHABBAN-DEV;Initial Catalog=TimeTable;Integrated Security=True"/>
  </connectionStrings>
 <membership defaultProvider="SqlProvider" userIsOnlineTimeWindow="15">
      <providers>
        <clear/>
        <add name="SqlProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="membershipConnectionString" applicationName="/" enablePasswordRetrieval="false" enablePasswordReset="true" requiresUniqueEmail="true" passwordFormat="Hashed"/>
      </providers>
    </membership>

注意到成员部分中的connectionStringName属性正在使用连接字符串部分中的membershipConnectionString。

我希望这个答案会对你有所帮助。
相关文章: