我正在尝试将AspNetMembershipProvider配置为用于在使用basicHttpBinding的WCF服务中进行身份验证。我有以下配置:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="basicSecureBinding">
<security mode="Message"></security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="MyApp.Services.ComputersServiceBehavior">
<serviceAuthorization roleProviderName="AspNetSqlRoleProvider" principalPermissionMode="UseAspNetRoles" />
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="AspNetSqlMembershipProvider"/>
</serviceCredentials>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="MyApp.Services.ComputersServiceBehavior" name="MyApp.Services.ComputersService">
<endpoint binding="basicHttpBinding" contract="MyApp.Services.IComputersService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
已启用角色并已配置成员资格提供程序(其适用于网站)。
但是根本不会激活身份验证过程。请求期间没有数据库的calles,当我尝试在方法上设置以下属性时:
[PrincipalPermission(SecurityAction.Demand, Authenticated = true)]
public bool Test()
{
return true;
}
我正在获取访问被拒绝的异常。有任何想法如何解决它?