HttpContext 为空?
是否可以这样说:当 Httpcontext 对象为 null 时,iis 就关闭了?
我知道当第一个请求iis(asp.net)时,应用程序管理器创建
环境:应用程序域。
其中有应用程序运行时。
在它里面有一些 HttpApplication 块(如果服务器上有超过 1 个应用程序),
每个都有 httpContext,它处理响应和请求。
那么当我进入 asp.net HttpContext 为 null 时这意味着什么?
Is it right to say that when Httpcontext object is null - so the iis is down ?
i know that when the first request to iis ( asp.net) the application manager creates
enviroment : Application Domain.
inside it theres Application Runtime.
And inside it there's blocks of (if theres more then 1 application on the server)
HttpApplication with each has httpContext which handler Response and Request.
So what does it mean when i get in asp.net HttpContext is null ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为您可以运行任何 IIS 关闭的 ASP.NET 应用程序,这只是设计使然 :)
如果您有一段代码,其中
HttpContext.Current
为 null,那么您可能没有运行在 Web 服务器中,但以另一种方式,例如有时我们有设计为在 Web 应用程序中执行的类库,然后有人直接从 Windows 服务、控制台应用程序或单元测试项目引用这些程序集,当然还有没有 HttpContext !Web 服务也是如此,如果从 IIS 提供服务,则应该具有上下文,如果直接使用程序集引用而不是 Web 引用进行调用,则无法访问任何 HttpContext。
显示您的失败代码并描述您在何处/如何使用它,我们将了解为什么您的上下文在这种情况下为空。
I don't think that you can be running any ASP.NET application having IIS down, just by design :)
if you have a piece of code where the
HttpContext.Current
is null you are probably not running in the web server but somehow in another way, for example sometimes we have class libraries designed to be executed within the web application then somebody references those assemblies directly from a windows service, a console application or from the unit test project and of course there is no HttpContext !web services as well, if served from IIS should have the context, if directly called with assembly reference and not web reference, can't reach any HttpContext.
show your failing code and describe where/how you use it and we will see why your context is null in that case.