If it matters, this is in ASP.NET MVC2 – how do I do this – how do I apply the “id” parameter to the attribute? This following syntax obviously does not work 🙂
[AuthorizeProject(ProjectId = id)]
public ActionResult Browse(int id)
{
// Stuff
return View();
}
Instead of trying to set in the Attribute constructor, what about setting ProjectId in one of the event handlers? You would have access to the RouteData via the context object.
You just need to make sure that you use it on methods that have an id parameter or that you do some type of validation check in the OnAuthorization method.