here are code I’m using to do, but compiler says: An anonymous type cannot have multiple properties with the same name
context.MapRoute("RouteName", "statics/category/{fileName}",
new
{
controller = "myController",
action = "Index"
},
new
{
fileName = new fnRouteConstraint(),
fileName = new AnotherRouteConstraint()
});
The error is pretty straightforward: you’re creating an anonymous class with two properties that have the same name. It’d be the same as writing:
To fix the problem, you’ll have to create another IRouteConstraint that contains the logic from the two constraints you’re trying to pass. Example: http://nayyeri.net/custom-route-constraint-in-asp-net-mvc
EDIT:
If you want to “merge” two separate route constraints, you just need to create a third constraint like this: