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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
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/