设置默认的 AspNetSqlProvider 以指向远程数据库

发布于 2024-07-10 01:36:55 字数 142 浏览 10 评论 0原文

当启动一个需要使用成员资格提供程序的新项目时,我发现无法连接到包含成员资格数据库的远程数据库。

我运行了 aspnet_regsql 并能够在远程服务器上创建成员数据库,但是当我转到 ASPNET 配置(卡西尼开发服务器)时,它不会连接到远程服务器。

When starting a new project that required the use of membership providers I found that I could not connect to a remote database that contained the membership database.

I ran aspnet_regsql and was able to create the membership database on the remote server but when I go to ASPNET Configuration (cassini development server) it will not connect to the remote server.

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

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

发布评论

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

评论(4

半岛未凉 2024-07-17 01:37:00

解决方案如下:

步骤 1:启动 Visual Studio 命令提示符
类型:aspnet_regsql
指定您的服务器:if sqlexpress then server = hostname\sqlexpress
***********使用 Windows 身份验证

步骤 2:将其复制到 Web 配置.不要指定用户名或密码,因为您使用 Windows 身份验证连接,这就是我们集成 security =true 的原因。

步骤 3:将 Web 管理工具上的安全 > 身份验证类型更改为“来自 Internet”。

现在就享受吧。

Here is the solution:

step 1: Launch Visual Studio command prompt
Type: aspnet_regsql
Specify your server: if sqlexpress then server = hostname\sqlexpress
***********Use Windows Authentication

step 2: Copy this to web config.Dont specify username or password because ur connecting with windows authentication that’s why we have integrated security =true.

step 3 : Change security>Authentication type on web administration tool to "From the Internet".

Enjoy now.

☆獨立☆ 2024-07-17 01:36:59

第 2 步:复制此内容:

<remove name="LocalSqlServer"/>

<add name="LocalSqlServer" connectionString="Data Source=VMK\sqlexpress;Initial Catalog=commodity_exchange;Integrated Security=True" providerName="System.Data.SqlClient"/>

step 2: copy this:

<remove name="LocalSqlServer"/>

<add name="LocalSqlServer" connectionString="Data Source=VMK\sqlexpress;Initial Catalog=commodity_exchange;Integrated Security=True" providerName="System.Data.SqlClient"/>

南汐寒笙箫 2024-07-17 01:36:58
<membership>
       <providers>
           <clear/>
           <add name="AspNetSqlMembershipProvider"
               type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
               connectionStringName="aspnet_membership"
               enablePasswordRetrieval="false"
               enablePasswordReset="true"
               requiresQuestionAndAnswer="true"
               applicationName="/"
               requiresUniqueEmail="false"
               passwordFormat="Hashed"
               maxInvalidPasswordAttempts="5"
               minRequiredPasswordLength="7"
               minRequiredNonalphanumericCharacters="1"
               passwordAttemptWindow="10"
               passwordStrengthRegularExpression=""/>
       </providers>
   </membership>

我需要添加此行以使我的角色和个人资料工作人员基于会员级别工作:

   <profile>
       <providers>
           <clear/>
           <add name="AspNetSqlProfileProvider"
           connectionStringName="aspnet_membership"
           applicationName="/"
           type="System.Web.Profile.SqlProfileProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
       </providers>
   </profile>

   <roleManager enabled="true">
       <providers>
           <clear/>
           <add name="AspNetSqlRoleProvider"
           connectionStringName="aspnet_membership"
           applicationName="/"
           type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
           <add name="AspNetWindowsTokenRoleProvider"
           applicationName="/"
           type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
       </providers>
   </roleManager>   
<membership>
       <providers>
           <clear/>
           <add name="AspNetSqlMembershipProvider"
               type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
               connectionStringName="aspnet_membership"
               enablePasswordRetrieval="false"
               enablePasswordReset="true"
               requiresQuestionAndAnswer="true"
               applicationName="/"
               requiresUniqueEmail="false"
               passwordFormat="Hashed"
               maxInvalidPasswordAttempts="5"
               minRequiredPasswordLength="7"
               minRequiredNonalphanumericCharacters="1"
               passwordAttemptWindow="10"
               passwordStrengthRegularExpression=""/>
       </providers>
   </membership>

I needed to add this lines to get my Roles and Profile staff based on Membership class working:

   <profile>
       <providers>
           <clear/>
           <add name="AspNetSqlProfileProvider"
           connectionStringName="aspnet_membership"
           applicationName="/"
           type="System.Web.Profile.SqlProfileProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
       </providers>
   </profile>

   <roleManager enabled="true">
       <providers>
           <clear/>
           <add name="AspNetSqlRoleProvider"
           connectionStringName="aspnet_membership"
           applicationName="/"
           type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
           <add name="AspNetWindowsTokenRoleProvider"
           applicationName="/"
           type="System.Web.Security.WindowsTokenRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
       </providers>
   </roleManager>   
迷迭香的记忆 2024-07-17 01:36:57

经过大量搜索后,我发现 machine.config (c:\windows\Microsoft.NET\Framework\v2.0.50727\CONFIG) 中指定的默认成员资格提供程序始终指向在本地主机上运行的 SQL Server。

有一种方法可以在项目 web.config 中设置它,而不是修改 machine.config:

1) 设置远程数据库的连接字符串

    <connectionStrings>
      <add name="aspnet_membership" connectionString="<your_connection_string>"/>
    </connectionStrings>

2) 在 中重新定义默认值提供者:

  <membership>
    <providers>
        <remove name="AspNetSqlMembershipProvider"/>
        <add name="AspNetSqlMembershipProvider" 
            type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
            connectionStringName="aspnet_membership"
            enablePasswordRetrieval="false" 
            enablePasswordReset="true" 
            requiresQuestionAndAnswer="true" 
            applicationName="/" 
            requiresUniqueEmail="false" 
            passwordFormat="Hashed" 
            maxInvalidPasswordAttempts="5" 
            minRequiredPasswordLength="7" 
            minRequiredNonalphanumericCharacters="1" 
            passwordAttemptWindow="10" 
            passwordStrengthRegularExpression=""/>
    </providers>
  </membership>

是关键! 所有其他键/值均直接从 machine.config 获取

After much searching I found that the default Membership Provider specified in machine.config (c:\windows\Microsoft.NET\Framework\v2.0.50727\CONFIG) was always pointing to a SQL Server running on the localhost.

Instead of modifying machine.config there is a way to set it up in the projects web.config:

1) Setup the connection string to the remote database

    <connectionStrings>
      <add name="aspnet_membership" connectionString="<your_connection_string>"/>
    </connectionStrings>

2) In <system.web> redefine the default provider:

  <membership>
    <providers>
        <remove name="AspNetSqlMembershipProvider"/>
        <add name="AspNetSqlMembershipProvider" 
            type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 
            connectionStringName="aspnet_membership"
            enablePasswordRetrieval="false" 
            enablePasswordReset="true" 
            requiresQuestionAndAnswer="true" 
            applicationName="/" 
            requiresUniqueEmail="false" 
            passwordFormat="Hashed" 
            maxInvalidPasswordAttempts="5" 
            minRequiredPasswordLength="7" 
            minRequiredNonalphanumericCharacters="1" 
            passwordAttemptWindow="10" 
            passwordStrengthRegularExpression=""/>
    </providers>
  </membership>

The <remove name="AspNetSqlMembershipProvider"/> is key! All the other key/values were taken directly from machine.config

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文