Question

I use a child action in Home Controller like this:

  [OutputCache(Duration=30)]
    public ActionResult ChildAction()
    {
        Response.Write("Date Time is="+DateTime.Now);
        return View();
    }

Home.cshtml
<h2>About</h2>
<p>
   @Html.Action("ChildAction")  
</p>

but after run my asp.net mvc3.0 Project i get an error :

The view 'ChildAction' or its master was not found or no view engine supports the searched locations. The following locations were searched:

~/Views/Home/ChildAction.aspx
~/Views/Home/ChildAction.ascx
~/Views/Shared/ChildAction.aspx
~/Views/Shared/ChildAction.ascx
~/Views/Home/ChildAction.cshtml
~/Views/Home/ChildAction.vbhtml
~/Views/Shared/ChildAction.cshtml
~/Views/Shared/ChildAction.vbhtml

please help me how can i solve it thanks

Was it helpful?

Solution

You should have a view named "ChildAction", or in action you should return view as
return View("ViewName"); In summary, view name should be same as action name, not controller name as you did(You named view as "Home").

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top