我为需要基本密码保护的客户端设置了一个简单的预览网站。我正在使用表单身份验证和web.config
中指定的凭据。
所有works fine on my box (着名的遗言)
但是,当我部署到运行Win2008的生产网站时,身份验证代码会尝试打开SQL Server数据库(我没有引用web.config
中的任何SQL)。如何禁用此行为,以便身份验证基于我在web.config
中输入的凭据?
事件日志中的例外
无法连接到SQL Server数据库。
at System.Web.Management.SqlServices.GetSqlConnection(String server,String user,String password,Boolean trusted,String connectionString)
at System.Web.Management.SqlServices.SetupApplicationServices(String server,String user,String password,Boolean trusted,String connectionString,String database,String dbFileName,SqlFeatures features,Boolean install)
在System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName,String dataDir,String connectionString)
在System.Web.DataAccess.SqlConnectionHelper.EnsureSqlExpressDBFile(String connectionString)
...
System.Web.Management.SqlServices.GetSqlConnection上的System.Data.SqlClient.SqlConnection.Open()(String server,String user,String password,Boolean trusted,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>
答案 0 :(得分:11)
事实证明,在生产机器上,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>