I’m trying to specify a route configuration that will allow a url similar to:
/{any sequence of characters}/{any sequence of characters}/{mexid}
We’re currently redesigning an old system that used URLs of the previous format. Our new system has to catch these requests and redirect them to a new URL, but only if there are 3 URL parameters. It’s only the third parameter that I’m interested in.
This is the route mapping that I’m using:
routes.MapRoute(
null,
"{param1}/{param2}/{mexid}",
new { controller = "ShareClass", action = "FundFactsheet", mexid = "" }
);
the problem I’m having is that this is acting as a kind of catch-all for any invalid requests that come in, where I am only interested in this being the route for URLs with a mexid in them.
how can I define a route that will only apply to URLs that contain 3 parameters, only if the URL doesn’t already match another route that I’ve more specifically defined?
You might want to add route constraint (I haven’t tested it yet but I think it should answer your question)