ASP.NET路由不等于约束
-
08-10-2019 - |
题
我有这样的路线:
routes.MapRoute
(
"Profile",
"profile/{username}",
new { controller = "Profile", action = "Index" },
new { username = @"^(getmoreactivity)" }
);
这对所有用户都很好 但 我的情况是,我想达到一个措施进行发作。因此,我想对此约束,以说何时用户名不是getmoreactivity。不过只是不起作用。
我一直粘在RoutedeBugger上,并尝试过 @“ [^(getMoreactivity)]” @“ ^^(getMoreActivity)” @“^getMoreActivity” @“ @” [^getMoreActivity]”。好吧,我尝试了无数的事情,但没有解决我的问题。
您如何对整个词不限制?
解决方案
尝试:
routes.MapRoute
(
"Profile",
"profile/{username}",
new { controller = "Profile", action = "Index" },
new { username = "(?!getmoreactivity).*" }
);
?!
是一个lookahead: http://www.regular-expressions.info/refadv.html
......
不隶属于 StackOverflow