ASP.NET 中的 WCF 无法使用状态服务器
我在 ASP.NET 中托管 WCF 服务。 WCF 服务的大多数操作都需要 cookie。如果 ASP.NET 会话状态为“InProc”,则它可以正常工作。但是,我们希望将应用程序移动到网络农场和网络农场。我想在专用机器上运行状态服务。当我这样做时,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" />
I'm hosting a WCF service within ASP.NET. The WCF service requires a cookie for most operations. It works fine if ASP.NET session state is "InProc". However, we want to move the app to a web farm & I'd like to run the State Service on a dedicated machine. When I do this, the WCF methods do not generate the cookie.
Any ideas?
Code to add the cookie:
WebOperationContext.Current.OutgoingResponse.Headers[HttpResponseHeader.SetCookie] = "myCookie" + MyVal.ToString();
WCF configuration:
<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" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论