【问题标题】:Disable SQL Membership Provider (ASP.Net Forms Authentication)禁用 SQL 成员资格提供程序(ASP.Net 表单身份验证)
【发布时间】:2011-07-25 18:23:01
【问题描述】:

我为需要基本密码保护的客户设置了一个简单的预览网站。我正在使用带有web.config 中指定凭据的表单身份验证。

一切works fine on my box(著名的遗言)

但是,当我部署到运行 Win2008 的生产网站时,身份验证代码会尝试打开 SQL Server 数据库(web.config 中我没有引用任何 SQL)。如何禁用此行为,以便身份验证基于我在 web.config 中输入的凭据?

事件日志中的异常

无法连接到 SQL Server 数据库。 在 System.Web.Management.SqlServices.GetSqlConnection(字符串服务器,字符串用户,字符串密码,布尔值信任,字符串 connectionString) 在 System.Web.Management.SqlServices.SetupApplicationServices(字符串服务器,字符串用户,字符串密码,布尔信任,字符串连接字符串,字符串数据库,字符串 dbFileName,SqlFeatures 功能,布尔安装) 在 System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(字符串 fullFileName,字符串 dataDir,字符串 connectionString) 在 System.Web.DataAccess.SqlConnectionHelper.EnsureSqlExpressDBFile(字符串连接字符串) ... 在 System.Data.SqlClient.SqlConnection.Open() 在 System.Web.Management.SqlServices.GetSqlConnection(String server, String user, String password, Boolean trust, String connectionString)
http://my.site.com/Login.aspx?ReturnUrl=/

web.config(相关部分)

     <system.web>
        <compilation targetFramework="4.0" />
    <authentication mode="Forms">
      <forms name="appNameAuth" path="/" loginUrl="Login.aspx" protection="All" timeout="30">
        <credentials passwordFormat="SHA1">
          <user name="me" password="SHA1OfMyPassword" />
        </credentials>
      </forms>
    </authentication>
    <authorization> 
      <deny users="?"/>  
      <allow users="me" />
    </authorization>    

  </system.web>

【问题讨论】:

    标签: asp.net asp.net-membership


    【解决方案1】:

    事实证明,在生产机器上,SQL 成员资格提供程序是在 machine.config 中定义的。我认为运营团队没有对默认的 Windows 2008 安装进行任何更改,因此该平台可能通常是这种情况。

    要删除对更高级别定义的任何 SQL 提供程序的引用,请在您的 web.config 中包含以下内容

    <membership>
        <providers>
            <clear />       
        </providers>
    </membership>
    <roleManager enabled="false">
        <providers>
            <clear />       
        </providers>
    </roleManager>
    <profile>
        <providers>
            <clear />       
        </providers>
    </profile>
    

    【讨论】:

    • 谢谢。这与此处概述的“enableSimpleMembership”条目一起回答了我的问题:stackoverflow.com/questions/12116736/…
    • 上述链接 (12116736) 中该解决方案的缺失部分是: 部分中的
    猜你喜欢
    • 2012-02-11
    • 1970-01-01
    • 2011-03-27
    • 1970-01-01
    • 2012-07-17
    • 2011-02-06
    • 1970-01-01
    • 2014-11-16
    • 1970-01-01
    相关资源
    最近更新 更多