更改成员资格、角色等的默认连接字符串

发布于 2024-12-17 20:48:52 字数 242 浏览 0 评论 0原文

默认情况下,我的 Web 应用程序似乎使用 LocalSqlServer 作为连接字符串,用于任何应用程序服务,例如成员资格/角色/身份验证/等。

有什么方法可以更改默认连接字符串应该是什么?默认值是“LocalSqlServer”似乎很随意,我能够找到它的唯一方法是通过谷歌搜索大约两个小时。

我不想被迫将我的服务器连接命名为“LocalSqlServer”,并且我不知道这是否是我可能会覆盖的预先存在的项目。

By default, it seems like my web application is using LocalSqlServer as the connection string to use for any application services such as Membership/Roles/Authentication/etc.

Is there any way I can change what the default connection string should be? It seems so arbitrary that the default is "LocalSqlServer" and the only way I was able to find this was by googling for this for about two hours.

I don't want to be forced to have to name my server connection "LocalSqlServer" and I have no idea if this is a preexisting item that I might be overwriting.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千里故人稀 2024-12-24 20:48:53

是的,可以在 web.config 中设置这些连接字符串:

成员资格

<membership defaultProvider="SqlMembershipProvider">
  <providers>
      <add 
        name="SqlMembershipProvider" 
        type="System.Web.Security.SqlMembershipProvider" 
        connectionStringName="MyMembershipConnectionString"
       />
  </providers>
</membership>

角色

<roleManager defaultProvider ="SqlRoleProvider" >
   <providers>
     <add
       name="SqlRoleProvider" 
       type="System.Web.Security.SqlRoleProvider" 
       connectionStringName="MyRolesConnectionString"
     />
   </providers>
</roleManager>

请参阅此处了解更多信息:如何:使用 ASP.NET 成员资格提供程序

Yes, these connection strings can be set in web.config:

Membership

<membership defaultProvider="SqlMembershipProvider">
  <providers>
      <add 
        name="SqlMembershipProvider" 
        type="System.Web.Security.SqlMembershipProvider" 
        connectionStringName="MyMembershipConnectionString"
       />
  </providers>
</membership>

Roles

<roleManager defaultProvider ="SqlRoleProvider" >
   <providers>
     <add
       name="SqlRoleProvider" 
       type="System.Web.Security.SqlRoleProvider" 
       connectionStringName="MyRolesConnectionString"
     />
   </providers>
</roleManager>

See here for more info: How to: Use the ASP.NET Membership Provider

怼怹恏 2024-12-24 20:48:53

2件事。
在您的会员配置中查找或添加“connectionStringName”属性。

这是一个使用它的示例

<system.web>
 ...
 <membership defaultProvider="MembershipADProvider">
  <providers>
    <add
      name="MembershipADProvider"
      type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, 
            Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                connectionStringName="YOUR CONN STRING" 
                connectionUsername="<domainName>\administrator" 
                connectionPassword="password"/>
   </providers>
 </membership>
 ...
</system.web>

,当然你需要设置 conn sting

<connectionStrings>
  <add name="YOUR CONN STRING" 
   connectionString=
    "[ANY ConnectionSTRIN]" />
</connectionStrings>

2 things.
Look for, or add a "connectionStringName" property in your membership config.

Here is an example that uses it

<system.web>
 ...
 <membership defaultProvider="MembershipADProvider">
  <providers>
    <add
      name="MembershipADProvider"
      type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, 
            Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
                connectionStringName="YOUR CONN STRING" 
                connectionUsername="<domainName>\administrator" 
                connectionPassword="password"/>
   </providers>
 </membership>
 ...
</system.web>

And you need to setup the conn sting of course

<connectionStrings>
  <add name="YOUR CONN STRING" 
   connectionString=
    "[ANY ConnectionSTRIN]" />
</connectionStrings>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文