具有“不等于”约束的 ASP.NET 路由
我有一条像这样的路线:
routes.MapRoute
(
"Profile",
"profile/{username}",
new { controller = "Profile", action = "Index" },
new { username = @"^(getmoreactivity)" }
);
这对所有用户都适用但是我有一种情况,我想点击 getmoreactivity 的操作。所以我想用这个约束来说明用户名何时不是 getmoreactivity。但它只是不起作用。
我一直坚持 RouteDebugger 并尝试了 @"[^(getmoreactivity)]" @"^^(getmoreactivity)" @"^getmoreactivity" @"[^getmoreactivity]"。好吧,我尝试了无数的方法,但没有一个能解决我的问题。
你怎么给整个单词加上 NOT 约束呢?
I have a route like so:
routes.MapRoute
(
"Profile",
"profile/{username}",
new { controller = "Profile", action = "Index" },
new { username = @"^(getmoreactivity)" }
);
This works fine for all users but I have a situation where I want to hit an action for getmoreactivity. So I want to make this constraint to say when username is NOT getmoreactivity. It's just not working though.
I've stuck on the RouteDebugger and tried @"[^(getmoreactivity)]" @"^^(getmoreactivity)" @"^getmoreactivity" @"[^getmoreactivity]". Well I've tried countless things but none solve my problem.
How the hell do you put in a NOT constraint on a whole word?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试:
?!
是一个前瞻: http://www.regular- Expressions.info/refav.html......
try:
?!
is a lookahead: http://www.regular-expressions.info/refadv.html......