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

前端 未结 7 993
不思量自难忘°
不思量自难忘° 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 18:01

    In ~/Views/ViewStart.cshtml:

    @{
        Layout = Request.IsAjaxRequest() ? null : "~/Views/Shared/_Layout.cshtml";
    }
    

    and in the controller:

    public ActionResult Index()
    {
        return View();
    }
    
    0 讨论(0)
提交回复
热议问题