简体   繁体   中英

WebMatrix WebData InitializeDatabaseConnection

I have placed the call to WebSecurity.InitializeDatabase in the _appstart.cshtml as noted in various google searches but periodically I keep receiving the below error when making subsequent calls to WebSecurity.IsAuthenticated for example, I would assume the initialisedatabase is called once for every user entering the website, is there a delay in this initialization before the _pagestart.cshtml is called?

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()

No, there should not be a delay.

To use WebSecurity.InitializeDatabaseConnection, you call once ever with the parameter autoCreateTables= true. After your tables are setup in your database, then from then on in _appstart, you'll call WebSecurity.InitializeDatabaseConnection with autoCreateTables = False.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM