HttpContext.Current is null when checked on interc

2019-09-01 08:07发布

My asp.net application have form authentication. When user logs in, he is redirected to a new page abc.aspx. On this page, in javascript, on document.ready, a service call is made to some service which have AspNetCompatibilityMode on. In the interceptor of the service, I try to find the HttpContext.Current but when its the first request to the application, interceptor does not get HttpContext.Current and is found null. After that, its never null but only on the first request to the application.

2条回答
小情绪 Triste *
2楼-- · 2019-09-01 08:13

Correctly said by Peer, there is no HttpContext in WCF. You may use OperationContext.Current.RequestContext

You would have to follow below link

http://www.danrigsby.com/blog/index.php/2008/05/23/understanding-instancecontext-in-wcf/

查看更多
唯我独甜
3楼-- · 2019-09-01 08:29

If you use WCF, in the wcf there is no HttpContext.Current. You have to use the InstanceContextMode of the Service class in the Session.

查看更多
登录 后发表回答