Skip to content

Instantly share code, notes, and snippets.

@sebnilsson
Created March 8, 2013 12:19
Show Gist options
  • Save sebnilsson/5116106 to your computer and use it in GitHub Desktop.
Save sebnilsson/5116106 to your computer and use it in GitHub Desktop.
RouteConstraint for actions that starts with "Get"
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