2

Can we cache Model in Partial View if not NULL. So that if my page make a round trip it will still have values in model.

Because i have an action that returns a list of records based on search parameters.

and that list is bound to the grid. This grid has paging.

so when i click on 2nd page, this grid is making a round trip to the partial view and second time the model in that partial view is empty.

Can any one suggest a best approach to not to loose data in model.

here i can't do output cache for the Action that returns result list.

any idea would be greatly appreciated.

thanks

tereško
  • 58,060
  • 25
  • 98
  • 150
HaBo
  • 13,999
  • 36
  • 114
  • 206

2 Answers2

0

MVC is a RESTful architecture, you have to provide the data/Model to your View from the Controller on each request.

If you decide to use OutputCache or other mechanisms, make sure your application can fall back and get the real resources. Cache in general can get removed by the server for various reasons and should not be relied in order for your functionality to work. Caching should be used for performance and scalability.

Take a look at the PagedList.

rick schott
  • 21,012
  • 5
  • 52
  • 81
0

You can add the Cache attribute to your controller, it works a treat.

[OutputCache(Duration=60,VaryByParam="ParamA;ParamB;")]
public PartialViewResult CachableAction(string SomeParameter)
{
...
}
Michael D. Irizarry
  • 6,186
  • 5
  • 30
  • 35
  • I go it done, actually the situation was a bit difficult for me to explain on this board. But what ever I could get this done. – HaBo Oct 07 '11 at 19:31
  • Thank you all for responding to my question – HaBo Oct 07 '11 at 19:31