Is there a way to set convention when returning a partial view? For example:
I have the following:
HomeController ---> Home(action Method) --> _Home.ascx (partial view)
AboutController ---> About(action Method) --> _About.ascx (partial view)
I’m currently passing the partial view name explicitly to the PartialView helper(ie return PartialView(“_home”);)
note: without using T4MVC.
Thanks
The MVC runtime component that’s responsible for mapping a view name to the right file is called a ViewEngine. In case of ascx files it’s the default WebFormViewEngine. It exposes properties that contain the default lookup patterns. For example you could modify
PartialViewLocationFormatsand instead of this:to be this:
Note that this change will apply to all of your partial view lookups.