Okay I\'m very new to C# and i\'m trying to create a little website using ASP MVC2.
I want to create my own authorization attribute. but i need to pass some values i
Use the value provider:
public class CustomAuthorizeAttribute : FilterAttribute, IAuthorizationFilter
{
public void OnAuthorization(AuthorizationContext filterContext)
{
var result = filterContext.Controller.ValueProvider.GetValue("GroupId"); //groupId should be of type `ValueProviderResult`
if (result != null)
{
int groupId = int.Parse(result.AttemptedValue);
//Authorize the user using the groupId
}
}
}
This article may help you.
HTHs,
Charles