I have the following routes in my ASP.NET MVC application:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "AppCode",
url: "AppCode",
defaults: new { controller = "AppToken", action = "AuthenticateUser", authCode = UrlParameter.Optional }
);
routes.MapRoute(
name: "ReplayFileRoute",
url: "Replays/{replayName}/{fileName}",
defaults: new { controller = "Replay", action = "GetReplayFile" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
The problem is now that the following URL will cause a 404, and the "GetReplayFile"-Action not to be executed:
http://localhost:59174/Replays/kgm3eauw.zbg/raha5qit.ikp.pls
However, the following URL works:
http://localhost:59174/Replays/kgm3eauw.zbg/raha5qit.ikp.pls/
So when I add an tailing slash, ASP chooses the right route, else it does not. Adding a tailing slash isn't an option at this time, since the URLs will be generated by an external script. I do only pass
http://localhost:59174/Replays/kgm3eauw.zbg/
to the script, the actual file name will be generated by the script - without the tailing slash.
So my question is: How do I make the first URL to call the "right" method?
Also: Is there any documentation on how the RouteConfig exactly works? I haven't found much so far.