ASP.NET MVC响应滤波器+的OutputCache属性 [英] ASP.NET MVC Response Filter + OutputCache Attribute

查看:104
本文介绍了ASP.NET MVC响应滤波器+的OutputCache属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道这是否是一个ASP.NET MVC特定事物或ASP.NET一般但这里发生了什么。我有一个动作的过滤器,通过使用响应滤波器消除空白:

I'm not sure if this is an ASP.NET MVC specific thing or ASP.NET in general but here's what's happening. I have an action filter that removes whitespace by the use of a response filter:

public class StripWhitespaceAttribute : ActionFilterAttribute
{
	public StripWhitespaceAttribute ()
	{

	}

	public override void OnResultExecuted(ResultExecutedContext filterContext)
	{
		base.OnResultExecuted(filterContext);

		filterContext.HttpContext.Response.Filter = new WhitespaceFilter(filterContext.HttpContext.Response.Filter);
	}
}

在与,OutputCache属性一起使用时,我对Response.WriteSubstitution呼吁甜甜圈洞高速缓存不工作。页面加载传递到WriteSubstitution回调所述第一和第二时间被调用,在这之后,直到输出缓存过期它们不再被调用。我已经不只是这个特殊的过滤器,但是,Response.Filter使用滤光片注意到这一点......我失去的东西吗?

When used in conjunction with the OutputCache attribute, my calls to Response.WriteSubstitution for "donut hole caching" do not work. The first and second time the page loads the callback passed to WriteSubstitution get called, after that they are not called anymore until the output cache expires. I've noticed this with not just this particular filter but any filter used on Response.Filter... am I missing something?

我也忘了提,我通过附加到Global.asax的PostReleaseRequestState事件,并设置Response.Filter值有试过这种无需使用MVC行为过滤器的属性...但仍然没有运气。

I also forgot to mention I've tried this without the use of an MVC action filter attribute by attaching to the PostReleaseRequestState event in the global.asax and setting the Response.Filter value there... but still no luck.

推荐答案

知识库文章可能提供一些洞察到这一问题的根本原因。虽然过滤器'游'在IIS6的缓存,它抛出在IIS 7的错误这似乎是一个设计/测试时间改善的最好的。

This KB article may offer some insight into the root cause of this issue. While the filter 'breaks' caching in IIS6 it throws an error in IIS 7. This seems to be a design / test-time improvement at best.

下面是对这个问题的批复答案,从MS开发的支持。

Here's an official "answer" from MS Dev Support on this issue.

问:

什么是替代响应过滤在ASP.NET由另一个进程时呈现修改HTML:

1.其它进程不能被修改

2.缓存后替换必须支持

Question:
What is the alternative to response filtering in ASP.NET for modifying HTML rendered by another process when:
1. The other process cannot be modified
2. Post-cache substitution must be supported

答:

是的,你的问题是清楚的蓝天,这是官方声称是不能支持的。至于同时响应过滤期望过滤响应的原始字节缓存后替换将一定的替代块相结合的响应字节(不修改)所以在previously组合替代块不能再pserved $ p $。

Answer:
"Yes, you question is clear as blue sky and this is officially claimed to be not support. As Post-cache substitution would combine certain substitution chunks to the response bytes while response filtering expects to filter the raw bytes of the response(not modified). So the previously combined substitution chunks cannot be preserved anymore.

有没有从微软迄今的替代品。

There is not an alternative from Microsoft so far."

这篇关于ASP.NET MVC响应滤波器+的OutputCache属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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