在第二个请求期间WCF服务中的HttpContext.Current [英] HttpContext.Current in WCF service during 2nd request

查看:59
本文介绍了在第二个请求期间WCF服务中的HttpContext.Current的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个Silverlight(4.0)应用程序正在调用WCF服务.在第一次调用WCF服务期间,一些数据是从HttpContext.Current.Session对象获取的.

There is a Silverlight (4.0) application that is calling to WCF-service. During 1st call to WCF-service some data are get from HttpContext.Current.Session object.

在第二次调用WCF服务HttpContext.Current期间为​​空...您是否知道原因(以及解决方法)?

During 2nd call to WCF-service HttpContext.Current is null... Do you have any idea why (and how to fix that)?

当前设置:

  1. 在web.config中将选项"aspNetCompatibilityEnabled"和"runAllManagedModulesForAllRequests"设置为true,
  2. 服务定义如下:

  1. Options "aspNetCompatibilityEnabled" and "runAllManagedModulesForAllRequests" are set to true in the web.config,
  2. Service definition looks like this:

[ServiceContract(Namespace =")]

[ServiceContract(Namespace = "")]

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]

公共类ElitaDataService{

public class ElitaDataService {

P.S.从WCF服务使用HttpContext的目的是检查:一种.如果当前用户已登录(此信息存储在会话中);b.如果用户使用自己的数据(例如,仅查看自己的订单详细信息).

P.S. The purpose to use HttpContext from the WCF service is to check: a. if current user is logged (this information is stored in Session); b. if user works with own data (look only own order details, for example).

P.P.S.我看到建议使用OperationContext代替HttpContext,但是尚不清楚OperationContext中的哪些属性可以帮助解析项目"a"和"b".

P.P.S. I saw that OperationContext is suggested to be used instead of HttpContext, but it's not clear what are properties in the OperationContext that would help to resolve items "a" and "b".

请告知,谢谢.

推荐答案

这很神奇...现在HttpContext.Current在每个请求期间都不为空...不知道为什么...如果知道为什么可能-请让我知道.

It's a magic... now HttpContext.Current is non-null during each request... don't know why... If you know why that's possible - please let me know.

这篇关于在第二个请求期间WCF服务中的HttpContext.Current的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆