Ultimo controllo, questo richiede di creare il proprio ViewEngine. Non so se hanno reso più facile in RC1 però.
L'approccio di base che ho usato prima del primo RC era, nel mio ViewEngine, per dividere lo spazio dei nomi del controller e cercare cartelle che corrispondessero alle parti.
EDIT:
Sono tornato e ha trovato il codice. Ecco l'idea generale.
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;
}
Ecco un altro esempio di una semplice ViewEngine da Rob Connery MVC Commercio app: [Visualizza codice motore] (http://mvcsamples.codeplex.com/SourceControl/changeset/view/17126#286681) E il codice Global.asax.cs per impostare ViewEngine: [Global.asax.cs] (http: //mvcsamples.codeplex. it/SourceControl/changeset/view/17126 # 286569) Spero che questo aiuti. –