ASP.NET Routing with NOT Equal Constraint

I have a route like this:

routes.MapRoute ( "Profile", "profile/{username}", new { controller = "Profile", action = "Index" }, new { username = @"^(getmoreactivity)" } ); 

This works great for all users , but . I have a situation where I want to click an action for getmoreactivity. Therefore, I want this restriction to say when the username does NOT get much activity. It just doesn't work though.

I got stuck in RouteDebugger and tried @ "[^ (getmoreactivity)]" @ "^^ (getmoreactivity)" @ "^ getmoreactivity" @ "[^ getmoreactivity]". Well, I tried countless things, but nobody solves my problem.

How the hell do you put a NOT clause on a whole word?

+6
asp.net-mvc asp.net-mvc-routing routing asp.net-routing
source share
1 answer

to try:

 routes.MapRoute ( "Profile", "profile/{username}", new { controller = "Profile", action = "Index" }, new { username = "(?!getmoreactivity).*" } ); 

?! is a look: http://www.regular-expressions.info/refadv.html

......

+16
source share

All Articles