I try to create and WCF Service Host and MVC client application. Everything works fine when i retrieve data from mvc client through method in wcf. But i have problem with authentication. I try to define a method in a service to login using WebSecurity.Login
and i got this error :
To call this method, the "Membership.Provider" property must be an instance of "ExtendedMembershipProvider".
Here is my login method
public bool Login(string username,string password)
{
try
{
if (!WebSecurity.Initialized)
WebSecurity.InitializeDatabaseConnection("DreamlandShopEntities",
"UserProfile", "UserId", "UserName", true);
if (WebSecurity.Login(username, username))
return true;
}
catch (FaultException ex)
{
return false;
}
return false;
}
and here is my Web.config file
<?xml version="1.0"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http:
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
</configSections>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<bufferedReceive maxPendingMessagesPerChannel="700000"/>
<!--<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="SimpleMembershipProvider"/>
</serviceCredentials>-->
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="webHttpConfig" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferPoolSize="20000000" messageEncoding="Mtom">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<!--<security mode="Message">
<message clientCredentialType="UserName"/>
</security>-->
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="InternetShop.Service.ShopService" behaviorConfiguration="mexBehavior">
<endpoint address="ShopService" binding="wsHttpBinding" bindingConfiguration="webHttpConfig" contract="InternetShop.Service.IShopService">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost:8723/ShopService/"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
<connectionStrings>
<add name="DreamlandShopEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string="data source=dreamland\dreamland;initial catalog=DreamlandShop;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient"/>
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb"/>
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>
</entityFramework>
<system.web>
<roleManager enabled="true"/>
<!--<roleManager enabled="true"/>
<membership defaultProvider="SimpleMemberShipProvider" userIsOnlineTimeWindow="15">
<providers>
<clear/>
<add name="SqlMembershipProvider" type="WebMatrix.WebData.SimpleMembershipProvider"
connectionStringName="DreamlandShopEntities" applicationName="InternetShop.MVC"
enablePasswordRetrieval="false" enablePasswordReset="false" requiresQuestionAndAnswer="false"
requiresUniqueEmail="true" passwordFormat="Hashed"/>
</providers>
</membership>-->
</system.web>
<appSettings>
<add key="enableSimpleMembership" value="true"/>
<add key="autoFormsAuthentication" value="true"/>
</appSettings>
</configuration>
Any hint? Thanks in advance