Created
June 16, 2023 16:46
-
-
Save SerenityInAllThings/44faa8c14d54d2916a243d79adfe4b1c to your computer and use it in GitHub Desktop.
.net 3.1 QueryStringRequiredAttribute
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 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