我在ASP.NET中托管WCF服务。对于大多数操作,WCF服务需要cookie。如果ASP.NET会话状态是“InProc”,它可以正常工作。但是,我们希望将应用程序移动到Web场和我想在专用机器上运行State Service。当我这样做时,WCF方法不会生成cookie。
有什么想法吗?
添加Cookie的代码:
WebOperationContext.Current.OutgoingResponse.Headers[HttpResponseHeader.SetCookie] = "myCookie" + MyVal.ToString();
WCF配置:
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="secure">
<security mode="Transport" />
</binding>
<binding name="basic"></binding>
</webHttpBinding>
</bindings>
<services>
<service name="MyService" behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="webHttpBinding" contract="MyService.Interface" behaviorConfiguration="web" bindingConfiguration="secure" />
<endpoint address="" binding="webHttpBinding" contract="MyService.Interface" behaviorConfiguration="web" bindingConfiguration="basic" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" httpHelpPageEnabled="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp defaultOutgoingResponseFormat="Json" faultExceptionEnabled="true" defaultBodyStyle="Bare" automaticFormatSelectionEnabled="false" />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />