views:

471

answers:

1

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?

A: 

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.

JTew