0

I'm having trouble finding a place where this is explained clearly.

If I have a custom view engine in my ASP.NET MVC project like this (example - I've seen this pattern used in other examples, as well):

public class ProjViewEngine : RazorViewEngine
{
    public ProjViewEngine()
    {
        //add new locations for the engine to look for partial views/editor templates
        base.PartialViewLocationFormats = new string[] 
        {
            // Record Partials
            "~/Views/Foo/{0}.cshtml",
            "~/Views/Foo/{1}/{0}.cshtml",
        }.Union(base.PartialViewLocationFormats).ToArray<string>();
    }
}

I understand when the BarController (for example) has a method that returns PartialView("_Bar", model), it finds the view at "~/Views/Foo/_Bar.cshtml".

I don't understand how/where {1} will get its value in "~/Views/Foo/{1}/{0}.cshtml".

The PartialView method can only take a string view name and an object model. There's no way to specify a second string parameter.

Is it part of the routing then? From the controller name?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
CarenRose
  • 1,266
  • 1
  • 12
  • 24

0 Answers0