Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save SerenityInAllThings/44faa8c14d54d2916a243d79adfe4b1c to your computer and use it in GitHub Desktop.
Save SerenityInAllThings/44faa8c14d54d2916a243d79adfe4b1c to your computer and use it in GitHub Desktop.
.net 3.1 QueryStringRequiredAttribute
public class QueryStringRequiredAttribute : Attribute, IActionConstraint
{
public int Order => 0;
public string Name { get; set; }
public QueryStringRequiredAttribute(string queryStringName)
{
Name = queryStringName;
}
public bool Accept(ActionConstraintContext context)
=> context.RouteContext.HttpContext.Request.Query.ContainsKey(Name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment