Reputation: 2074
I'm trying to put a constraint onto a route that does not want to work. Instead to provide a constraint with a list of controllers to allow, I am trying to restrict this route to all controllers except ProjectController.
context.MapRoute("Project_Projects",
"Project/{prj}/{controller}/{action}/{id}",
new { controller = "Dashboard", action = "Index",
id = UrlParameter.Optional },
new
{
prj = new ProjectRouteConstraint(),
controller = @"[^Project]"
}
);
This route should be used for all controllers except for the ProjectController. As far as the documentation go it will uses Regex.IsMatch function to check it, and I've double check the regular expression and seems correct, and but it does not seem to work.
Am I missing something?
Upvotes: 0
Views: 2932
Reputation: 1039398
Try the following constraint:
controller = @"^(?!project$).*$"
Upvotes: 2