在asp.net mvc中缓存用户控件或其相关数据的最佳方法是什么

时间:2023-01-14 20:06:48

I am in the middle of implementing an application using ASP.NET MVC and would love to cache the data passed to user controls or the output rendering on some user controls that I render using the Html.RenderPartial, that way I don't have to query the DB with every request I do to the controller for a new view.

我正在使用ASP.NET MVC实现一个应用程序,并希望缓存传递给用户控件的数据或我使用Html.RenderPartial渲染的一些用户控件的输出渲染,这样我就不必使用我对控制器的每个请求查询数据库以获取新视图。

2 个解决方案

#1


3  

That appears to be one of those 1 million dollar questions!

这似乎是100万美元的问题之一!

It seems that a lot of people are having that problem, but the solution is not trivial.

似乎很多人都有这个问题,但解决方案并非无足轻重。

Check out an issue reported recently on the ASP.NET MVC Codeplex site...

查看最近在ASP.NET MVC Codeplex站点上报告的问题...

#2


0  

I would maybe suggest using the sub controllers from the MVC Contrib and then caching the controller's method using the OutputCache stuff.

我建议使用MVC Contrib中的子控制器,然后使用OutputCache来缓存控制器的方法。

#1


3  

That appears to be one of those 1 million dollar questions!

这似乎是100万美元的问题之一!

It seems that a lot of people are having that problem, but the solution is not trivial.

似乎很多人都有这个问题,但解决方案并非无足轻重。

Check out an issue reported recently on the ASP.NET MVC Codeplex site...

查看最近在ASP.NET MVC Codeplex站点上报告的问题...

#2


0  

I would maybe suggest using the sub controllers from the MVC Contrib and then caching the controller's method using the OutputCache stuff.

我建议使用MVC Contrib中的子控制器,然后使用OutputCache来缓存控制器的方法。