这对我来说是在 IIS7.5 64 位上运行的 .Net 3.5 SP1 的问题(我尝试强制使用 32 位但得到了相同的结果)。
我有一个想要使用身份验证服务的 WCF 服务。当我没有任何行为时,WCF 服务会在没有任何错误的情况下进行绘制(回复)。其他服务也适用于其他行为
只要我将 userNameAuthentication 添加到指定自定义 MembershipProvider 以对服务进行身份验证的行为...
<serviceCredentials>
<!-- Configure user name authentication to use the Membership Provider -->
<userNameAuthentication userNamePasswordValidationMode ="MembershipProvider"
membershipProviderName ="MembershipService"/>
</serviceCredentials>
该服务崩溃并返回以下错误:
Parser Error Message: Default Membership Provider could not be found.
Source Error:
Line 49: </authentication>
Line 50:
Line 51: <membership defaultProvider="MembershipService" userIsOnlineTimeWindow="15">
Line 52: <providers>
Line 53: <clear/>
事件日志有这个错误:
WebHost failed to process a request.
Sender Information: System.ServiceModel.Activation.HostedHttpRequestAsyncResult/59884855
Exception: System.ServiceModel.ServiceActivationException: The service '/V4Service.svc' cannot be activated due to an exception during compilation. The exception message is: Default Membership Provider could not be found. (C:\Code\SmartTrade Projects\SmartTrade.API\Web\SmartTrade.API\web.config line 50). ---> System.Configuration.ConfigurationErrorsException: Default Membership Provider could not be found. (C:\Code\SmartTrade Projects\SmartTrade.API\Web\SmartTrade.API\web.config line 50)
at System.Web.Security.Membership.Initialize()
at System.Web.Security.Membership.get_Providers()
at System.ServiceModel.Configuration.UserNameServiceElement.ApplyConfiguration(UserNamePasswordServiceCredential userName)
at System.ServiceModel.Configuration.ServiceCredentialsElement.ApplyConfiguration(ServiceCredentials behavior)
at System.ServiceModel.Configuration.ServiceCredentialsElement.CreateBehavior()
at System.ServiceModel.Description.ConfigLoader.LoadBehaviors[T](ServiceModelExtensionCollectionElement`1 behaviorElement, KeyedByTypeCollection`1 behaviors, Boolean commonBehaviors)
at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase host, ServiceDescription description, ServiceElement serviceElement, Action`1 addBaseAddress)
at System.ServiceModel.ServiceHostBase.ApplyConfiguration()
at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses)
at System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses)
at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses)
at System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.CreateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.ActivateService(String normalizedVirtualPath)
at System.ServiceModel.ServiceHostingEnvironment.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath)
我很确定这不是提供程序或提供程序配置的问题,因为我有这个自定义提供程序与 ASP MVC 站点一起使用。
有什么想法吗?