ASP.NET MVC > Partial view

Returning a partial view from controller action method in ASP.NET MVC

How to return a partial view from controller action method?


To return a Partial view from the controller action method, we can write return type as PartialViewResult and return using PartialView method.

public PartialViewResult OutputPartialView()
  {
      return PartialView("_GetFileName"); // returns view with model
  }

In the above code, we are assuming that _GetFileName.cshtml exists in the controller specific folder otherwise we need to specify the complete file name of the view from the root of the application (like "~/Views/PersonalDetails/_ViewName").

 Views: 70757 | Post Order: 52



Write for us






Hosting Recommendations