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