I have a child class of AuthorizeAttribute named CheckArticleExistence.
I would like to set an attribute using the parameter that I receive in the action. Like this:
This one worked (thanks!):
[CheckArticleExistence]
public ActionResult Tags(int articleId)
{
...
}
...
public class CheckArticleExistenceAttribute : AuthorizeAttribute
{
private int articleId;
public override void OnAuthorization(AuthorizationContext filterContext)
{
this.articleId = int.Parse(filterContext.RouteData.Values["id"].ToString());
if (!Article.Exists(articleId))
{
...
}
}
}