I have a controller 'QUnitController', then I have a folder in my Views folder 'QUnit'. In that folder I have a _ViewStart.cshtml thats coded to use the _Layout file within this folder for the Views in the QUnit folder. For some reason the _ViewStart.cshtml in the Views folder is being called and not my _ViewStart.cshtml within the QUnit folder. What am I doing wrong here? I thought having this file in the folder would override the one in the route. I can place break points in the _ViewStart files and I see the one I want is never being hit. Can anyone tell me what I'm doing wrong?
Here is controller code. QUnitController.cs
public class QUnitController : Controller
{
public ActionResult LoadView(string viewName)
{
return View(viewName);
}
}
Here is route Views/_ViewStart.cshtml
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
Here is qunit Views/QUnit/_ViewStart.cshtml
@{
Layout = "~/Views/QUnit/_Layout.cshtml";
}
Why am I not calling the correct _ViewStart? Can anyone help me correct the problem? I appreciate any help or tips anyone may have.
Thanks,
~ck in San Diego
All _ViewStart files in every parent folder are executed; the outermost one is executed first.
Your ~/Views/QUnit/_ViewStart.cshtml should be executed last.
Are you sure that your view is coming from the correct folder?
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