When doing
return PartialViewResult(string viewName, object model)
where does the constructor for PartialViewResult look for a View? For instance, if we have two views with the same name in our Views folder (at different locations, of course). Which one he picks up?
What if we have two views named Create.aspx and Create.ascx? Does PartialViewResult pick up only ascx file (given that PartialViewResult is mostly used with ViewUserControls)?
And finally, if开发者_开发技巧 I make my own ViewEngine and set PartialViewLocationFormats the way I want it, will it use it? I actually have this in place already but as of right now I am unable to test it by myself, so if you've tried it out please respond.
Partial view will be searched in these locations in this order:
- "~/Views/{1}/{0}.aspx"
- "~/Views/{1}/{0}.ascx"
- "~/Views/Shared/{0}.aspx"
- "~/Views/Shared/{0}.ascx"
{1} will be replaced with controller name and {0} with action or partial view name (your case).
And yes, if you create view-engine derived from VirtualPathProviderViewEngine then PartialViewLocationFormats will be used.
精彩评论