So I have a controller called myPartiaViewController with the path
Controllers/myPartiaViewController.cs
and I have a partial view, _mypartialView, inside a folder, myPartialView, that is inside another folder, MainView, in the Views folder
Views/MainView/myPartialView/_myPartialView.cshtml
I have a method in my controller
[HttpPost]
[ChildActionOnly]
public ActionResult myPartialView()
return PartialView("MainView/myPartialView/_myPartialView.cshtml", model);}
}
For some reason my controller can not resolve the partial view. what going on?
Use return PartialView("~/Views/MainView/PartialView/_myPartialView.cshtml", model);
it's the ~ that does it. Otherwise you'll look for a top-level MainView folder, which is not as intended.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With