Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Last I checked, this requires you to build your own ViewEngine. I don't know if they made it easier in RC1 though.</p> <p>The basic approach I used before the first RC was, in my own ViewEngine, to split the namespace of the controller and look for folders which matched the parts.</p> <p><strong>EDIT:</strong></p> <p>Went back and found the code. Here's the general idea.</p> <pre><code>public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName) { string ns = controllerContext.Controller.GetType().Namespace; string controller = controllerContext.Controller.GetType().Name.Replace("Controller", ""); //try to find the view string rel = "~/Views/" + ( ns == baseControllerNamespace ? "" : ns.Substring(baseControllerNamespace.Length + 1).Replace(".", "/") + "/" ) + controller; string[] pathsToSearch = new string[]{ rel+"/"+viewName+".aspx", rel+"/"+viewName+".ascx" }; string viewPath = null; foreach (var path in pathsToSearch) { if (this.VirtualPathProvider.FileExists(path)) { viewPath = path; break; } } if (viewPath != null) { string masterPath = null; //try find the master if (!string.IsNullOrEmpty(masterName)) { string[] masterPathsToSearch = new string[]{ rel+"/"+masterName+".master", "~/Views/"+ controller +"/"+ masterName+".master", "~/Views/Shared/"+ masterName+".master" }; foreach (var path in masterPathsToSearch) { if (this.VirtualPathProvider.FileExists(path)) { masterPath = path; break; } } } if (string.IsNullOrEmpty(masterName) || masterPath != null) { return new ViewEngineResult( this.CreateView(controllerContext, viewPath, masterPath), this); } } //try default implementation var result = base.FindView(controllerContext, viewName, masterName); if (result.View == null) { //add the location searched return new ViewEngineResult(pathsToSearch); } return result; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload