MapRoute for passing a parameter to the root of the site causing JavaScript errors on certain script references

68 views Asked by At

I am using this code to map a route for the root of my site.

   routes.MapRoute("InstanceLogIn", "{InstanceParameter}", 
new { controller = "Account", action = "Login" });

So the URL will be similar to "MySite/SomeParameter" and this will route it to the log in page and pass the parameter.

This works but the issue is when i deploy this site some script references don't work, it seems for some reason they are also using this route.

For example this reference is not returning the script but instead following the route and therefore throwing a JavaScript error

 "MySite/ScriptResource.axd?d=UsKo6CSewZbLohzBYSPi2REunQLB9VJ1DCCMF8dLkLy"

For some reason this script works fine however in my development environment. It is definitely the route that is causing the error as if i remove it the script resources are correctly called. What could be the reason for this?

1

There are 1 answers

1
Andy T On BEST ANSWER

You need to explicitly ignore this route so that MVC does not try to route anything with .axd. Simply add:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}")