0

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?

2 Answers 2

2

Do this:

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

Instead of:

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

Notice the closing script tag at the end.

Sign up to request clarification or add additional context in comments.

1 Comment

0

I would look at FireBug and see what is loading. Are you using a virtual directory, if so the preceding slash will cause problems.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.