2012-10-24 23 views
0

我已經設置了運行SQl Server Web版本和完整IIS 7.5的遠程服務器。我能沒有問題,我的MVC 4應用程序部署到遠程機器,但是當我嘗試運行我收到以下錯誤網站:接收到執行代碼的錯誤第一個MVC web部署

Login failed for user 'IIS APPPOOL\backoffice.mysite.com'. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'IIS APPPOOL\backoffice.mysite.com'. 

錯誤控制檯說:

Exception information: 
    Exception type: InvalidOperationException 
    Exception message: The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588 
    at MyModels.Filters.InitializeSimpleMembershipAttribute.SimpleMembershipInitializer..ctor() in c:\Users\Administrator\Documents\MySite\MyModels\Filters\InitializeSimpleMembershipAttribute.cs:line 47 

An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct. 

它非常有可能我的連接字符串不正確,如錯誤日誌所示。在Visual Studio本地運行我的連接是:

<add name="MyDB" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=MyDB;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\MyDB.mdf" providerName="System.Data.SqlClient" /> 

我已成立了一個轉型爲作爲遠程服務器上的連接:

<add name="MyDB" connectionString="Data Source=(local);Initial Catalog=MyDb;Integrated Security=True" providerName="System.Data.SqlClient" /> 
  1. 通常我使用SQL登錄,所以我很困惑這裏。連接字符串應該使用Windows身份驗證查找SQL Server Web Edition的內容?

  2. 它看起來像IIS APPPOOL \ backoffice.mysite.com是試圖創建數據庫。它是否正確?如果是這樣,我不需要在SQL Management Studio中爲此用戶創建登錄名和用戶?

  3. 是否需要在運行部署之前在SQL Management Studio中創建數據庫?

非常感謝!

回答

1

您正在使用Windows Authentintication for SQL Server運行。 IIS應用程序在「IIS APPPOOL \ backoffice.mysite.com」的用戶環境下運行;我強烈建議使用標準sql服務器憑證或爲具有sql憑證的特定網站創建新用戶,但使用常規憑證可能會更好。集成安全性=連接字符串中的SSPI表示Windows身份驗證。因此,只需使用標準的SQL Server憑據並將您的數據庫設置爲混合模式身份驗證並在連接字符串中設置用戶標識和密碼,然後您就可以運行並且沒有任何問題。

+0

這改正了它,謝謝! –