我已经在_appstart.cshtml中调用了WebSecurity.InitializeDatabase,如各种谷歌搜索中所述,但是在对WebSecurity进行后续调用时,我会不断收到以下错误。例如,我认为初始化数据库会被调用一次对于每个进入网站的用户,在调用_pagestart.cshtml之前,这个初始化是否有延迟?
You must call the "WebSecurity.InitializeDatabaseConnection" method before you call any other method of the "WebSecurity" class. This call should be placed in an _AppStart.cshtml file in the root of your site.
at WebMatrix.WebData.SimpleMembershipProvider.VerifyInitialized()
at WebMatrix.WebData.WebSecurity.VerifyProvider()
at WebMatrix.WebData.WebSecurity.Logout()
at ASP._Page__PageStart_cshtml.Execute()
答案 0 :(得分:0)
不,不应该有延迟。
要使用WebSecurity.InitializeDatabaseConnection,请使用参数autoCreateTables = true调用一次。在数据库中设置表之后,从那时起_appstart中,您将使用autoCreateTables = False调用WebSecurity.InitializeDatabaseConnection。