2011-03-30 101 views
3

我爲需要基本密碼保護的客戶端設置了一個簡單的預覽網站。我使用的表單身份驗證使用web.config中指定的憑據。禁用SQL成員提供程序(ASP.Net Forms身份驗證)

一切works fine on my box(鬼才)

然而,當我部署到運行的Win2008生產網站,驗證碼試圖打開一個SQL Server數據庫(我有沒有提到什麼SQL in web.config)。如何禁用此行爲,以便身份驗證基於我在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 ,字符串的connectionString,字符串數據庫,字符串dbFileName,SqlFeatures特徵,布爾安裝) 在System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(字符串fullFileName,字符串DATADIR,字符串的connectionString) 在System.Web.DataAccess.SqlConnectionHelper.EnsureSqlExpressDBFile(字符串連接字符串) ... at System.Data.SqlClient.SqlConnection.Open()at System.Web.Management.SqlServices.GetSqlConnection(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> 

回答

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> 
+0

謝謝。這回答了我的問題以及這裏列出的「enableSimpleMembership」條目:http://stackoverflow.com/questions/12116736/aspnet-role-provider-kicking-in-and-it-shouldnt-be – Josh 2013-08-12 11:05:52

+1

此解決方案的缺失部分從上面的鏈接(12116736)是: 部分 – Nigel 2013-09-02 08:20:59

相關問題