0

さまざまなグーグル検索で指摘されているように、_appstart.cshtmlでWebSecurity.InitializeDatabaseを呼び出しましたが、WebSecurity.IsAuthenticatedを後で呼び出すと、定期的に以下のエラーが発生します。たとえば、initialisedatabaseはユーザーごとに1回呼び出されると思います。ウェブサイトに入ると、_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()
4

1 に答える 1

0

いいえ、遅れてはいけません。

WebSecurity.InitializeDatabaseConnection を使用するには、パラメーター autoCreateTables= true を使用して一度だけ呼び出します。データベースにテーブルをセットアップしたら、それ以降は _appstart で、autoCreateTables = False を指定して WebSecurity.InitializeDatabaseConnection を呼び出します。

于 2012-12-13T14:52:11.643 に答える