在MVC4应用程序中,我使用SimpleMemberShip作为auth数据库。 安全模型是:
<binding name="SecureBasicBindingWithMembershipConfig">
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
</binding>
它适用于网页。它需要SSL以及用户登录。问题出在WCF服务中。
当我尝试使用服务时,我得到InvalidOperationException: 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.
此错误是正确的,这意味着我需要在服务器应用程序授权用户凭据之前调用InitializeDatabaseConnection。我在哪里可以调用InitializeDatabaseConnection?
答案 0 :(得分:0)
在Global.asax
事件的Application_Start()
中调用它:
protected void Application_Start()
{
WebSecurity.InitializeDatabaseConnection(yourParameters);
}