Webforms 中的 Outputcaching VarietyByParams 是否理解路由参数?
Webforms 中的输出缓存 VaryByParams 是否理解路由参数?这样,如果我有类似于 "Content/{filename}/{more}"
的路线,我可以执行 VaryByParams="filename"
并让它返回基于缓存的结果关于文件名并忽略 more 中的任何值?
Does outputcaching VaryByParams in webforms understand route parameters? Such that if I have a route similar to "Content/{filename}/{more}"
that I could do VaryByParams="filename"
and have it return cached results based on filename and ignore any values in the more?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
VaryByParam 仅在 HTTP 方法为 GET 时使用查询字符串,在 HTTP 方法为 POST 时使用参数(即表单中的值和查询字符串)。除非您使用查询字符串进行路由,否则我认为它不会起作用。
请查看@OutputCache 的文档。
http://msdn.microsoft.com/en-us/library/hdxfb6cy。 aspx
也许您可以考虑在页面后面的代码中使用 C# 编写自己的缓存,而不是依赖 @OutputCache。
VaryByParam only work with query string when HTTP method is GET, and parameters (i.e. values in the form and query string) when HTTP method is POST. Unless you are using query string for routing I do not think that it will work.
Please take a look at the documentation of @OutputCache.
http://msdn.microsoft.com/en-us/library/hdxfb6cy.aspx
May be you can consider writing your own caching using C# in the code behind of the page instead of relying on @OutputCache.