Skip to content

Instantly share code, notes, and snippets.

@Dynyx
Created June 4, 2012 13:10
Show Gist options
  • Save Dynyx/2868269 to your computer and use it in GitHub Desktop.
Save Dynyx/2868269 to your computer and use it in GitHub Desktop.
Custom validation attribute with current context
public Func<HttpContextBase> ContextProvider = () => new HttpContextWrapper(HttpContext.Current);
public override bool IsValid(object value)
{
if (value == null) return false;
var identityName = ContextProvider().User.Identity.Name;
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment