Asp.net-mvc – C# MVC FindPartialView cannot find the path

asp.net-mvcasp.net-mvc-3asp.net-mvc-4

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.

Best Answer

Try this, it is working in MVC3

ViewName should contain whole path like ~/Views/Shared/_Create.cshtml

 ViewEngineResult viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName);