1

我有一个当前使用的 WCF 服务basicHttpBindinguserNamePasswordValidationMode并且 TransportWithMessageCredential,这是我的配置:

<behavior name="Secure">
      <serviceMetadata httpsGetEnabled="true" httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <serviceCredentials>
        <userNameAuthentication userNamePasswordValidationMode="Custom"
                                customUserNamePasswordValidatorType="Kestrel.MIS3.Server.Services.Security.LoginAuthentication, Kestrel.MIS3.Server.Services" />
      </serviceCredentials>
      <serviceAuthorization principalPermissionMode="Custom">
        <authorizationPolicies>
          <add policyType="Kestrel.MIS3.Server.Services.Security.AuthorizationPolicy, Kestrel.MIS3.Server.Services"/>
        </authorizationPolicies>
      </serviceAuthorization>
<behaviour>

<services>
  <service name="Kestrel.MIS3.Server.Services.UserService" behaviorConfiguration="Secure">
    <endpoint address=""
              binding="wsHttpBinding"
              bindingConfiguration="wsSecure"
              contract="Kestrel.MIS3.Server.Services.IUserService" />
    <endpoint address="mex"
              binding="mexHttpsBinding"
              contract="IMetadataExchange" />
  </service>
</services>

<wsHttpBinding>
    <binding name="wsSecure">
      <reliableSession enabled="true"/>
      <security mode="TransportWithMessageCredential">
        <message clientCredentialType="UserName" />
      </security>
    </binding>
  </wsHttpBinding>

我希望能够使用会话,以便在创建服务实例时我不需要每次都查找用户详细信息。这可能吗?

我用以下内容标记了服务,但没有运气:

[ServiceContract(SessionMode = SessionMode.Required)]    
public interface IUserService

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
public class UserService : ServiceBase, IUserService
4

0 回答 0