Skip to content

Instantly share code, notes, and snippets.

@nevzatalkan
Created December 4, 2016 12:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nevzatalkan/53daaaebffdfed16e426f8e94ae5a85b to your computer and use it in GitHub Desktop.
Save nevzatalkan/53daaaebffdfed16e426f8e94ae5a85b to your computer and use it in GitHub Desktop.
C# how to get the filled parameter names from request maching with the action parameters excluding default asp.net and http headers etc..
public class LogonAuthorize : AuthorizeAttribute
{
var parameters = context.ActionDescriptor.GetParameters();
var contextParams = parameters.Select(s => s.ParameterName.ToLowerInvariant()).
Intersect(context.RequestContext.HttpContext.Request.Params.AllKeys.
Select(x=>!string.IsNullOrEmpty(context.RequestContext.HttpContext.Request.Params[x])
? x.ToLowerInvariant() : null));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment