How to use Object caching on View page MVC

47 Views Asked by At

I am working MVC project. I am having access of view page only in one project which I load using view engine.

Now I want to use object caching on view page as I do not want to call service method every time.

Is there any way to do this? Any help is appreciated. Thanks.

1

There are 1 best solutions below

1
Dilip Oganiya On

You can cache your View like this :

[OutputCache(Duration = 10)]
public ActionResult Details(int id)
        {
            ViewData.Model = _dataContext.Movies.SingleOrDefault(m => m.Id == id);
            return View();
        }