HttpContext.Current上拦截检查时为空 [英] HttpContext.Current is null when checked on interceptor

查看:172
本文介绍了HttpContext.Current上拦截检查时为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的asp.net应用程序有形式的认证。当用户登录时,他将被重定向到一个新的页面abc.aspx。在这个页面上,在JavaScript上的document.ready,一个服务调用的一些服务,有AspNetCompatibilityMode上进行。在服务的拦截器,我试图找到HttpContext.Current,但是当其应用程序的第一个请求,拦截器并没有得到HttpContext.Current和发现空。在这之后,其不能为null但只在第一次请求发送到应用程序。

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.

推荐答案

如果您使用WCF,WCF中没有HttpContext.Current。你必须使用本服务类的InstanceContextMode在Session。

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.

这篇关于HttpContext.Current上拦截检查时为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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