Created
March 8, 2013 12:19
-
-
Save sebnilsson/5116106 to your computer and use it in GitHub Desktop.
RouteConstraint for actions that starts with "Get"
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
public class ActionStartsWithGetConstraint : IRouteConstraint | |
{ | |
public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) | |
{ | |
var action = values["action"]; | |
if (action == null) | |
{ | |
return false; | |
} | |
string actionValue = Convert.ToString(action); | |
return actionValue.StartsWith("get", StringComparison.InvariantCultureIgnoreCase); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment