如何调试“找不到默认会员提供程序” WCF 和自定义 ASP.NET 成员资格提供程序出现错误?
这对我来说是在 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 站点一起使用。
有什么想法吗?
This is problem for me with .Net 3.5 SP1 running on IIS7.5 64 bit (I tried forcing 32 bit but got the same result).
I have a WCF service that I want to use authentication-services with. When I have no behavior the WCF service paints (replies) without any error. Other services also work with other behaviors
As soon as I add userNameAuthentication to the behaviour specifying a custom MembershipProvider for authentication to a service ...
<serviceCredentials>
<!-- Configure user name authentication to use the Membership Provider -->
<userNameAuthentication userNamePasswordValidationMode ="MembershipProvider"
membershipProviderName ="MembershipService"/>
</serviceCredentials>
The service blows up and returns the following error:
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/>
Event Log has this error:
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)
I'm pretty sure this isn't an issue with the provider or provider config as I have this custom provider working with an ASP MVC site.
Any thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我从头开始了一个新的自定义提供程序实现,确保所有覆盖都正确返回。我原来的那个我认为可以工作(那是几个月前的事),但事实证明它不再工作了。
事实证明,如果您的配置中的提供程序名称正确并且类型正确,则只会留下您的自定义提供程序实现。
因此,如果您遇到此问题并且确定您的配置正确,请使用简单的 ASP.net 或 ASP.net MVC 网站验证您的实现。
I started a new Custom Provider implementation from scratch ensuring all the overrides were correctly returning. My original one that I thought was working (that was a couple of months ago) and it turns out it no longer worked.
It turns out if you have the Provider Name correct and the Type correct in configuration that only leaves your Custom Provider implementation.
So if you have this issue and you are sure your config is correct, verify your implementation with a simple ASP.net or ASP.net MVC website.
我收到此错误并最终发现隐藏的 UTF8 或 Unicode 字符已进入我的 web.config 文件。我必须删除部分才能确定应用程序字符串部分已损坏。
当我从旧版本替换它后,它又可以工作了。有些字符串中有多余的空白,这是可疑的,我不确定它是否可能是剪切和粘贴或其他什么造成的。您也可以尝试使用十六进制编辑器查看 web.config 文件。
I got this error and eventually discovered that hidden UTF8 or Unicode characters had found their way into my web.config file. I had to delete sections to figure out that the application strings section was corrupted.
Once I replaced it from an older version, it worked again. Some of the strings had extra white space in them that was suspect, I am not sure if it could have been from cut and paste or what. You can try looking at your web.config file with a hex editor too.
我也遇到了同样的问题,花了将近一周的时间才解决。我的问题是我必须将 Name 属性覆盖设置为 web.config 的提供程序名称中的相同值。我讨厌最简单的解决方案如此难以找到!
I had this same problem and spent almost a week figuring it out. My problem was that I had to set the Name property override to the same value that was in the web.config's provider name. I hate it when the simplest solutions are so hard to find!