Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing custom membership provider in a wcf service error
    primarykey
    data
    text
    <p>I have an asp.net mvc 4 web application where I have created a custom membership provider (inheriting from MembershipProvider base class). In the same solution but in another project I have a wcf service where I want to authenticate a user using the ValidateUser method from my membership provider (which is called KinematMembershipProvider)</p> <p>This is my interface of the service</p> <pre><code>[ServiceContract] public interface IKinematService { [OperationContract] bool AuthenticateUser(string username, string password); } </code></pre> <p>and the actual service</p> <pre><code>public class KinematService : IKinematService { public bool AuthenticateUser(string username, string password) { KinematMembershipProvider membershipProvider = (KinematMembershipProvider)Membership.Providers["KinematMembershipProvider"]; return membershipProvider.ValidateUser(username, password); } } </code></pre> <p>and this is my app.config file</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;configuration&gt; &lt;!--configSections--&gt; &lt;configSections&gt; &lt;section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /&gt; &lt;/configSections&gt; &lt;!--appSettings--&gt; &lt;appSettings&gt; &lt;add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /&gt; &lt;/appSettings&gt; &lt;!--connectionStrings--&gt; &lt;connectionStrings&gt; &lt;add name="KinematDbContext" providerName="System.Data.SqlClient" connectionString="Data Source=.;Initial Catalog=KinematDatabase;Integrated Security=SSPI;" /&gt; &lt;/connectionStrings&gt; &lt;!--system.web--&gt; &lt;system.web&gt; &lt;!--compilation--&gt; &lt;compilation debug="true" /&gt; &lt;!--membership--&gt; &lt;membership defaultProvider="KinematMembershipProvider"&gt; &lt;!--providers--&gt; &lt;providers&gt; &lt;add name="KinematMembershipProvider" type="Kinemat.Web.Infrastructure.KinematMembershipProvider" connectionStringName="KinematDbContext" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="true" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" passwordFormat="Encrypted" /&gt; &lt;/providers&gt; &lt;/membership&gt; &lt;/system.web&gt; &lt;!--system.serviceModel--&gt; &lt;system.serviceModel&gt; &lt;!--services--&gt; &lt;services&gt; &lt;service name="Kinemat.WebServices.KinematService" behaviorConfiguration="ProviderServiceBehavior"&gt; &lt;endpoint address="http://localhost:52174/WcfServices/Kinemat" binding="wsHttpBinding" bindingConfiguration="MembershipBinding" contract="Kinemat.WebServices.IKinematService"&gt; &lt;/endpoint&gt; &lt;/service&gt; &lt;/services&gt; &lt;!--bindings--&gt; &lt;bindings&gt; &lt;wsHttpBinding&gt; &lt;binding name="MembershipBinding"&gt; &lt;security mode ="Message"&gt; &lt;message clientCredentialType ="UserName" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/wsHttpBinding&gt; &lt;/bindings&gt; &lt;!--behaviors--&gt; &lt;behaviors&gt; &lt;!--serviceBehaviors--&gt; &lt;serviceBehaviors&gt; &lt;behavior name="ProviderServiceBehavior"&gt; &lt;serviceCredentials&gt; &lt;userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="KinematMembershipProvider" /&gt; &lt;/serviceCredentials&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;/system.serviceModel&gt; &lt;!--entityFramework--&gt; &lt;entityFramework&gt; &lt;defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"&gt; &lt;parameters&gt; &lt;parameter value="v11.0" /&gt; &lt;/parameters&gt; &lt;/defaultConnectionFactory&gt; &lt;/entityFramework&gt; &lt;/configuration&gt; </code></pre> <p>When I run my service I get the following error <strong>System.TypeLoadException: Could not load type 'Kinemat.Web.Infrastructure.KinematMembershipProvider' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.</strong></p> <p>I cannot figure out why it is trying to search in System.Web assembly. Please do you have any suggestion? Please ask for any additional information if you need. Thank you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload