Reputation: 2420
I am using MVC4.I am trying to get the html string view.
ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName);
I am putting viewname as "create".But the return to viewResult is view is null and showing SearchedLocartion also like,
~/Views/LWWApplication/Create.aspx
~/Views/LWWApplication/Create.ascx
~/Views/Shared/Create.aspx
~/Views/LWWApplication/Create.cshtml
~/Views/Shared/Create.cshtml
Actually the forth one is the file (~/Views/LWWApplication/Create.cshtml).but return like not found.View and controller contains same folder structure.
Please Help.
Upvotes: 7
Views: 10791
Reputation: 61
Provide the full location of the partial to be rendered:
var viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, "~/Areas/AreaName/Views/Preferences/Email.cshtml");
Upvotes: 6
Reputation: 15387
Try this, it is working in MVC3
ViewName
should contain whole path like ~/Views/Shared/_Create.cshtml
ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName);
Upvotes: 19