views:

107

answers:

3

See the exception

I have a JS include in my master page and it seems to be tripping one of the routes every time.

Is tripping this route:

routes.MapRoute(
"CatalogType",
"Catalog/{group}/{type}/{index}/{browseSize}",
new { controller = "Catalog"
    , action = "Types"
    , group = ""
    , type = ""
    , index = ""
    , browseSize = "" }
);

Is there something I can do to stop this behavior?

PS: I know there is a way to enforce a datatype on these params but for the life of me I cannot find a reference. Am I dreaming?

A: 

can we see js code please?

Marko
A: 

Looking at the exception it looks like you're not resolving the virtual path to your javascript file properly on the serverside (i.e. the ~/ bit is ending up being rendered out to the client instead of being resolved into a proper application absoluet path). Where you include your js file you want to include it like this:

<script type="text/javascript" src="<%= Url.Content("~/scripts/swfobject.js") %>" ></script>

Not like this:

<script type="text/javascript" src="~/scripts/swfobject.js" ></script>
Alconja
A: 

Here's an overview of route constraints.

You can also use regular expressions like:

routes.MapRoute("CatalogType", "Catalog/{group}/{type}/{index}/{browseSize}",
    new { controller = "Catalog", action = "Types", group = "", type = "", index = "", browseSize = "" },
    new { group = "\w+", browseSize = "\d+" }
);

I have found Phil Haack's route debugger to be very useful for things like this as well.

Bryan