In ASP.NET MVC 2 project, how might I go about writing a custom view engine that allows custom tokens to be used when searching for views?
Specifically, I’m trying to achieve this:
In PagesController:
public ActionResult ViewPage(string folder, string page)
{
return View(folder, page);
}
I want the view engine to search for the view in the directory: /Views/Pages/[folder]/
How might I achieve this without knowing the folder names ahead of time? Ideally, this customized view engine would only be used for this single controller.
You don’t need to implement your own viewengine to solve this issue. You can simply supply the path to the view you want. Something like this:
You example could look something like this: