我已经在_appstart.cshtml中调用了WebSecurity.InitializeDatabase,就像在各种谷歌搜索中指出的那样,但在随后调用WebSecurity.IsAuthenticated时,我周期性地不断收到下面的错误。例如,我假设每个进入网站的用户都会调用initialisedatabase一次,在调用_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()发布于 2012-12-13 22:52:12
不,不应该有延误。
要使用WebSecurity.InitializeDatabaseConnection,只需使用参数autoCreateTables= true调用一次。在数据库中设置好表之后,从那时起在_appstart中,您将使用autoCreateTables = False来调用WebSecurity.InitializeDatabaseConnection。
https://stackoverflow.com/questions/13856864
复制相似问题