Outputcache不适用于路由

Outputcache不适用于路由

本文介绍了Outputcache不适用于路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在标准ASP.Net Web应用程序项目应用程序中使用不带MVC的System.Web.Routing路由。这主要是为了在我们正在开发的门户网站中获得更整洁的URL(而不是〜/ default.aspx?contentid = 123我们拥有〜/ {contentsubject}。该门户网站未经授权,并且所有信息都在URL中,因此在缓存中)

I'm using routing from System.Web.Routing without MVC in a standard ASP.Net Web Application Project application. This is mostly done to get neater urls in the portal we are developing (instead of ~/default.aspx?contentid=123 we have ~/{contentsubject}. The portal is not authorized and all info is in the url so in a caching scenario we can cache complete pages.

当我尝试启用输出缓存时,我注意到没有完成缓存,似乎outputcache page指令被完全忽略了。是真的还是我缺少什么?可以解决吗?

When I tried to enable output caching I noticed that no caching was done. It seems that the outputcache page directive is completely ignored. Is this true or am I missing something? Can this be fixed?

我做了一个小型测试应用程序(我将其上传到了),其中仅包含一个页面, Webform1.aspx,使用一个母版页和一个用户控件,所有这三个输出当前日期和时间。

I made a small test app (I uploaded it to http://www.4shared.com/file/196605919/31903b07/OutputCacheTest.html) that just contains a page, Webform1.aspx, that uses a master page and a user control. All three output the current date and time.

当我请求http // localhost / OutputcacheTest / Webform1时。 aspx 10秒缓存按预期工作,即,显示的时间仅每10秒更新一次

When I request http//localhost/OutputcacheTest/Webform1.aspx the 10 second caching works as expected, i.e. the shown time only updates every 10 seconds.

该应用程序还定义了一个通配符路由,该路由可捕获所有请求并返回与处理程序相同的Webform1.aspx。因此,当请求http // localhost / OutputcacheTest / myroute时,将执行同一页面,但是现在缓存不起作用,即,当前时间显示在每个请求上。

The app also defines a wildcard route that catches all requests and returns the same Webform1.aspx as a handler. So when requesting http//localhost/OutputcacheTest/myroute the same page is executed but now the caching doesn't work, i.e. the current time is shown on every request.

注意:使用内置开发Web服务器时,这两种情况都可以使用,但只有IIS似乎有此问题。

Note: When using the built-in development web server both scenarios work, only IIS seems to have this problem.

是否有人提供解决方案或解决该问题的方法在这种情况下是否输出缓存?

Does anyone have a a solution or work around for how to enable output caching in this scenario?

推荐答案

我通过使模块和处理程序注册完全像本文中所述()。

I got this working by making the module and handler registrations exactly like in this article (http://msdn.microsoft.com/en-us/magazine/dd347546.aspx).

以前我的注册信息排在最后,现在我将其移至顶部。我还在此块中添加了属性runAllManagedModulesForAllRequests = true

< system.webServer>

<验证validateIntegratedModeConfiguration = false />

< modules runAllManagedModulesForAllRequests = true>

Earlier I had my registrations last in the block and now I moved them to the top. I also added attribute runAllManagedModulesForAllRequests="true" in this block
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true">

所以现在outputcache页面指令正在工作!

So now outputcache page directive is working!

这篇关于Outputcache不适用于路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 15:09