我正在嘗試使用Windows Azure託管MVC4 Web應用程序。 我創建了一個測試應用程序,使用VS2012 MVC4互聯網應用程序模板並添加了一個自定義模型和控制器。WebSecurity.InitializeDatabaseConnection方法只能調用一次
我已經在Azure上發佈了它,並設法將'update-database'應用遷移應用到Azure數據庫。
當我在本地嘗試應用程序,但使用Azure SQL數據庫時,它工作正常。 我可以登錄/註冊並使用我的測試控制器。
當我在網上嘗試應用程序,我可以使用測試控制器,但登錄或註冊環節給予以下異常:
Server Error in '/' Application.
The "WebSecurity.InitializeDatabaseConnection" method can be called only once.
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.InvalidOperationException: The "WebSecurity.InitializeDatabaseConnection" method can be called only once.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The "WebSecurity.InitializeDatabaseConnection" method can be called only once.]
WebMatrix.WebData.WebSecurity.InitializeMembershipProvider(SimpleMembershipProvider simpleMembership, DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean createTables) +123
WebMatrix.WebData.WebSecurity.InitializeProviders(DatabaseConnectionInfo connect, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +51
WebMatrix.WebData.WebSecurity.InitializeDatabaseConnection(String connectionStringName, String userTableName, String userIdColumn, String userNameColumn, Boolean autoCreateTables) +52
MembershipTest2.Filters.SimpleMembershipInitializer..ctor() +193
你有哪裏是來自任何想法? 如果我調試(本地版本),這種方法只調用一次。
謝謝。
這是如何脫離主題?我有這個相同的問題。 –
其中是您調用WebSecurity.InitializeDatabaseConnection的代碼? – Nikos