Last active
December 19, 2015 10:29
-
-
Save curtismitchell/5940417 to your computer and use it in GitHub Desktop.
MVC route constraint that does not match a set of words (with help from http://stackoverflow.com/questions/6277022/regex-not-matching-a-list-of-words)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* must come before the default route (if still being used) | |
allows for routes like .../mycompany/projects/index/1 | |
uses the constraint to make sure system controller names can co-exist with workspace names | |
*/ | |
routes.MapRoute( | |
"Workspace", | |
"{workspace}/{controller}/{action}/{id}", | |
new { controller = "Projects", action = "Index", id = String.Empty }, | |
new { workspace = @"^(?!.*\bAccount\b)(?!.*\bHome\b).*$" } | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment