In my web application I will have a route like :
http://server/requests/info/{id}-{guidPart} (a string)
So I thought Id be clever and make a route so I did :
routes.MapRoute(
name: "Info",
url: "{controller}/{action}/{id}-{guidPart}",
defaults: new { controller = "Requests", action = "Info", id = 0, guidPart = "" }
);
Then I thought, why do I need to specify defaults, why not have it all fixed except the last part :
routes.MapRoute(
name: "Info",
url: "requests/info/{id}-{guidPart}"
);
But when I go to a url like :
http://server/requests/info/123-abc123
It fails and says :
404 Resource not found.
Any tips on what I am doing wrong?
You can have a static route, but you still have to specify which Controller and Action to route to by default.
The difference between this and the defaults above is that this UriTemplate will only try to match a Uri starting with “requests/info/”