2013-04-03 49 views
0

帶有使用表單身份驗證的帳戶控制器的默認ASP.NET MVC 4項目,但此身份驗證在我的服務器上的IIS 7.5上出現此錯誤。Internet應用程序

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.) 

我該如何解決這個問題,因爲我找不到類上的任何連接。

+0

你真的建立了一個數據庫嗎?你用什麼連接字符串? – levelnis 2013-04-03 20:53:32

回答

1

默認的MVC 4項目依託IIS Express和的LocalDB,將產生的LocalDB存儲在App_Data文件夾。

但是改變項目下建議您切換到使用的SQL Express完整的IIS運行時。爲此,您需要創建一個數據庫並設置相關的連接字符串。假定您的應用程序具有相關權限,並且WebSecurity.InitializeDatabaseConnection將autoCreateTables設置爲true,則會自動創建相關表。

默認的數據庫初始化是通過InitializeSimpleMembershipAttribute完成的,我們可以在Filters/InitializeSimpleMembershipAttribute.cs中找到,然後這個屬性被應用到AccountController。

+0

我的問題是EntityFramework與此連接不兼容。 – 2013-04-04 17:08:13

0

您應該檢查異常消息中建議的Windows日誌。連接字符串位於Web應用程序的web.config文件中。

+0

但是,這是在本地主機上,並在web.config 唯一連接「DefaultConnection」,我真的不知道登錄數據存儲在哪裏。 – 2013-04-03 21:01:55

+0

現在好了,我使用默認連接找到了WebSecurity.InitializeDatabaseConnection。現在我正在嘗試調試下一步。 – 2013-04-03 21:28:20

相關問題