I currently have an ASP.Net MVC 3 website that hosts a physical JavaScript file at this path: /bookmarklet/src.js. I’d like to make the content at the path to be the result of an MVC controller action so that I can make the output of this file dynamic.
How can I modify my website in order to send requests for this file to an action named “Src” on a controller named “Javascript”?
Here’s how I did it. You just need to add a custom route in your Global.asax file like this:
routes.MapRoute(“bookmarklet”,
“bookmarklet/src.js”,
new { controller = “Javascript”, action = “Src” });