Let’s say I want to forward all requests at /js/* to a JavaScript controller Index method. In other words, these routes should all invoke JavaScriptController.Index():
/js/root/index.css
/js/user/account/index.css
/js/master.css
What would the route definition be in my Global.asax.cs file?
This doesn’t seem to work:
routes.MapRoute("JavaScript", "js/{*path}",
new { controller = "JavaScriptController", action = "Index" });
The breakpoint is never invoked during Debug mode with:
public class JavaScriptController : Controller
{
[HttpGet]
public void Index(string path)
{
var browser = HttpContext.Request.Browser;
System.Diagnostics.Debugger.Break();
}
}
Am I missing something?
You should have the controller shortname in the route default values i.e:
This would work.