I want to implement something like facebook:
- after left-clicking on a photo, it loads via AJAX
- after a middle click on the scroll, it usually loads with an additional layout
Now I have a view that loads into the controller in two different ways:
public ActionResult Overview() { return View("Overview"); } public ActionResult OverviewPartialView() { return PartialView("Overview"); }
And in the jquery script it looks like this:
$(contentContainer).load(_link + 'PartialView');
My question is, is there a better way to solve this problem? I tried something like this in _ViewStart:
@{ Layout = "~/Views/Shared/_Layout.cshtml"; if (IsAjax) { Layout = null; } }
And something like this in the controller:
public ActionResult Index() { if (Request.IsAjaxRequest()) return PartialView(); return View(); }
But in those solutions, I had a cache problem, after opening the page with the layout, the page with the layout was also loaded in the AJAX request.
source share