I'm wanting for every view in my system to have some static help content. The way I was thinking about doing this would be to set up a parallel structure for the static content and create a route to rewrite the URL to this. For instance:
/Controllers
/Help
/Account
/Login.htm
/Create.htm
/Models
/Views
/Account
/Login.aspx
/Create.aspx
...where an incoming URL for "/Account/Create/Help
" would serve "/Help/Account/Create.htm
". How can I add that to Global.asax:RegisterRoutes(RouteCollection)
?
Or, is it better to instead handle this with a dedicated controller and action - such as:
public class HelpController : Controller
{
public ActionResult Help(string controller, string action)
{
return FileContentResult(GetContent("Help/" + controller + "/" + action));
}
}
Or some other way?
I ended up adding a route:
routes.MapAsyncRoute(
"Help",
"{helpController}/{helpAction}/help",
new { controller = "Help", action = "Help" }
);
which sends the help URLs to:
public ActionResult Help(string helpController, string helpAction)
{
return View(helpController + "_" + helpAction);
}
...and then named the help pages like "Account_Create.aspx
". This seems like the most effective way to handle this with MVC.