Securing an ADO.net WCF data service with ASP.NET Membership

佐手、 提交于 2020-01-06 05:06:28

问题


HI,

I am using WCF DataServices, i am trying to securing it using asp.net membership

here is my code,

<system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="SecureWSBindingWithMembershipConfig" >
          <security mode="TransportWithMessageCredential">
            <transport clientCredentialType="None" />
            <message clientCredentialType="UserName"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="SecureServiceWithMembershipBehavior">
          <serviceMetadata httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <serviceAuthorization principalPermissionMode="UseAspNetRoles" roleProviderName="AspNetSqlRoleProvider" />
          <serviceCredentials>
            <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="AspNetSqlMembershipProvider" />
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service name="DataService.WcfDataService" behaviorConfiguration="SecureServiceWithMembershipBehavior">
        <endpoint address="WcfDataService.svc" binding="wsHttpBinding" contract="System.Data.Services.IRequestHandler" bindingConfiguration="SecureWSBindingWithMembershipConfig" >
          <!--<identity>
              <dns value="" />
          </identity>-->
        </endpoint>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
  </system.serviceModel>

I am getting following error:

The operation 'ProcessRequestForMessage' could not be loaded because it has a parameter or return type of type System.ServiceModel.Channels.Message or a type that has MessageContractAttribute and other parameters of different types. When using System.ServiceModel.Channels.Message or types with MessageContractAttribute, the method must not use any other types of parameters.


回答1:


You can try this, if this is almost like your code:

Method(RequestMessage request, OtherType value)

// Your message contract much like this.
[MessageContract]
public class RequestMessage {
     [MessageBodyMember]
     public OtherType { get; set; }
}

// And your new method will be
Method(RequestMessage request)


来源:https://stackoverflow.com/questions/5816788/securing-an-ado-net-wcf-data-service-with-asp-net-membership

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!