title: MVC4 Route map JavaScript file to controller
body: <p>Here is an example of what I am trying do.</p>
  
  <p>Provide an MVC Route from test.js to a controller action e.g. </p>
  
  <pre><code>&gt; http://localhost/MVCScripts/test.js?id=123
  </code></pre>
  
  <p>to the controller</p>
  
  <pre><code>&gt; http://localhost/Home/RenderJavascript?id=123
  </code></pre>
  
  <p><em>The reason behind this is to produce a dynamic js file rendered from the server based on the id.  The JS file will be linked to by being embedded into other websites.</em></p>
  
  <p>I have tried setting the web.config to exclude the script folder in question:</p>
  
  <pre><code>&lt;handlers&gt;
       &lt;add name="scripts" path="/MVCScripts/*" verb="GET" type="System.Web.Handlers.TransferRequestHandler" /&gt;
  &lt;/handlers&gt;
  </code></pre>
  
  <p>and then added a route such as:</p>
  
  <pre><code>routes.MapRoute(
              name: "EmbedCode",
              url: "MVCScripts/test.js",
              defaults: new { controller = "Home", action = "RenderJavascript", id = UrlParameter.Optional }
          );
  </code></pre>
  
  <p>When invoking </p>
  
  <pre><code>&gt; http://localhost/MVCScripts/test.js?id=123
  </code></pre>
  
  <p>I just get </p>
  
  <pre><code>The controller for path '/MVCScripts/test.js' was not found or does not implement IController.
  </code></pre>
  
  <p>Note that my aim here is to use MVC Routing. Thanks</p>