本文介绍了在WebForms中使用system.web.routing时的状态服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在WebForms应用程序中使用System.Web.Routing程序集。运行在win2008 / IIS7上部署的应用程序时,我收到以下消息。

I am using the System.Web.Routing assembly in a WebForms application. When running the application deployed on win2008/IIS7 I got the following message.

这只是使用我配置的路由时的一个问题。直接导航到aspx页面时没有问题。

This is only a problem when using a route I have configured. It is not a problem when directly navigating to an aspx page.

EnableSessionState在web.config和Page指令中均已打开。我已将Session条目添加到web.config的httpmodule中。

EnableSessionState has been turned on in both the web.config and the Page directive. I have added the Session entry to httpmodule of the web.config.

在我的工作站上使用Visual Studio开发时,这不是问题。尝试在Win 2008上的IIS7下运行应用程序时,这只是一个问题。

This is not an issue when developing using Visual Studio on my workstation. It is only a problem when trying to run the application under IIS7 on Win 2008.

推荐答案

我遇到了同样的问题,并且我想我知道问题出在哪里。

I'm having the same issue and I think I know what the problem is.

我正在尝试在路由系统下实现FileNotFound页面(我尚未弄清的是如何给FileNotFound页面并在标题中给出404响应)

I'm trying to implement a FileNotFound page under the routing system (something I've yet to figure out is how to both give a FileNotFound page AND give a 404 response in the header)

我发现由于某种原因,在BuildManager中注册的页面似乎没有会话上下文(实际上并没有请求页面,只是实例化了!)。

What I've found, is that for some reason, the pages registered with BuildManager seem to be instanced without session context (the page was not actually requested, just instanced!).

至少看起来是这样。

我现在不太确定以前的主张了。显然,当图像请求在物理上不存在时,它们也会通过路由系统。当图像路径匹配时,这将导致调用 IRouteHandler 。我很确定在请求图像时会话对象不存在,因此在路由到该页面的页面尝试访问它时,可能会导致问题。

I'm now less sure of my previous assertion. Apparently, requests for images also go through the routing system when they do not exist on physically. This causes an IRouteHandler to be called when the image path matches. I'm pretty sure the session object does not exist when an image is requested, so that may cause the problem when the page that was routed to tries to access it.

这篇关于在WebForms中使用system.web.routing时的状态服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 19:01