禁用SQL成员提供者(ASP.Net表单验证)。

 2023-02-16    412  

问题描述

我已经为需要基本密码保护的客户设置了一个微不足道的预览网站.我正在使用表单身份验证以及web.config中指定的凭据.

所有工作正常我的盒子 (着名的最后一句话)

禁用SQL成员提供者(ASP.Net表单验证)。

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

事件日志

中的例外

无法连接到SQL Server数据库.
在system.web.management.sqlservices.getsqlconnection(String Server,String用户,字符串密码,布尔值得信任,String ConnectionString)
在System.Web.Management.sqlservices.setupApplicationservices(String Server,String用户,字符串密码,布尔值得信任,String ConnectionString,String数据库,字符串DBFileName,SQLFeatures功能,Boolean安装)
在system.web.dataAccess.sqlconnectionhelper.createmdffile(String fullfilename,string datadir,string connectionstring)
在system.web.dataAccess.sqlconnectionhelper.ensuresqlexpressdbfile(String ConnectionString)
……
在system.data.sqlclient.sqlconnection.open()AT system.web.management.getsqlconnection(String Server,String用户,字符串密码,布尔值得信任,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>

推荐答案

结果证明,在生产机上,SQL成员资格提供程序在Machine.config中定义.我不认为OPS团队从默认的Windows 2008安装中更改了任何内容,因此这通常是该平台的情况.

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

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

以上所述是小编给大家介绍的禁用SQL成员提供者(ASP.Net表单验证)。,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对77isp云服务器技术网的支持!

原文链接:https://77isp.com/post/34059.html

=========================================

https://77isp.com/ 为 “云服务器技术网” 唯一官方服务平台,请勿相信其他任何渠道。