sanyam tayal

sanyam tayal

  • 1.9k
  • 95
  • 269

dynamically Bind a Partial Page in mvc core application

May 6 2019 8:11 AM
How To Bind Partial Page in dot net mvc  core application using controller action method ?
In mvc application I used this Static Method , But In mvc Core this method gives an error. Can u suggest me How to Bind? 
public static string PartialView(Controller controller, string viewName, object model)
controller.ViewData.Model = model;
using (var sw = new StringWriter())
var viewResult = ViewEngines.Engines.FindPartialView(controller.ControllerContext, viewName);
var viewContext = new ViewContext(controller.ControllerContext, viewResult.View, controller.ViewData, controller.TempData, sw);
viewResult.View.Render(viewContext, sw);
viewResult.ViewEngine.ReleaseView(controller.ControllerContext, viewResult.View);
return sw.ToString();

Brought to you by:

Answers (1)