Problem with asp.net mvc route not firing when in <script> tag

Posted by Chev on Stack Overflow See other posts from Stack Overflow or by Chev
Published on 2010-03-18T05:43:53Z Indexed on 2010/03/18 5:51 UTC
Read the original article Hit count: 235

Filed under:

I cannot get the following route to fire when a url is requested from a script tag. I have the following route:

            // maps to "/cache/cachecontent/JavaScriptInclude/1/javascript"
            routes.MapRoute(
                null,
                "cache/{action}/{key}/{version}/{type}",
                new { controller = "Cache", action = "CacheContent", key = "", version = "", type = "" }
            );

I have a javascript script tag like:

<script type="text/javascript" src="/cache/cachecontent/JavaScriptInclude/1/javascript" />  

Yet the route is not firing and the controller is not instantiated. If i drop the url into the address bar of the browser all is fine, but is not triggered from the javascript tag?

Any ideas?

© Stack Overflow or respective owner

Related posts about asp.net-mvc