MVC 3: How to render a view without its layout page when loaded via ajax?

前端 未结 7 1028
不思量自难忘°
不思量自难忘° 2020-11-30 17:31

I am learning about Progressive Enhancement and I have a question about AJAXifying views. In my MVC 3 project I have a layout page, a viewstart page, and two plain views.

7条回答
  •  臣服心动
    2020-11-30 17:49

    Create two layout: 1. empty layout, 2 . main layout and then write in _viewStart file this code:

    @{
    if (Request.IsAjaxRequest())
    {
        Layout = "~/Areas/Dashboard/Views/Shared/_emptyLayout.cshtml";
    }
    else
    {
        Layout = "~/Areas/Dashboard/Views/Shared/_Layout.cshtml";
    }}
    

    of course, maybe it is not best solution

提交回复
热议问题