yad4u ASP MVC C#: Is it possible to pass dynamic values into an attribute?


ASP MVC C#: Is it possible to pass dynamic values into an attribute?



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 if this is possible.

For example:

    [CustomAuthorize(GroupID = Method Parameter?]     public ActionResult DoSomething(int GroupID)     {         return View("");     } 

I want to authorize the access to a page. but it depends on the value passed to the controller. So the authorization depends on the groupID. Is this possible to achieve this in any way?.

Thanks in advance.




Linq to SQL and Realtime Data

1:



what is the fastest grid components for asp.net mvc applications
Use the value provider:.
One repository per table or one per functional section?
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            }    } 
}.
What Good way to keep some different data in Cookies in asp.net?
This article may help you..
ASP MVC - Routing Required?
HTHs,

Can someone explain this block of ASP.NET MVC code to me, please?
Charles.
How make data entry using autogenerated texboxes in ASP.NET MVC?


Inline HTML Syntax for Helpers in ASP.NET MVC

2:


You get it from Request.Form.
public class CustomAuthorizeAttribute : AuthorizeAttribute {     protected override bool AuthorizeCore(HttpContextBase httpContext)     {        //httpContext.Request.Form["groupid"]         return base.AuthorizeCore(httpContext);     } } 


3:


You get it from Request.Form. public class CustomAuthorizeAttribute : AuthorizeAttribute { protected override bool AuthorizeCore(HttpContextBase httpContext) { //httpContext.Request.Form["groupid"] return base.AuthorizeCore(httpContext); } }.



82 out of 100 based on 52 user ratings 802 reviews