Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7168155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:43:20+00:00 2026-05-28T14:43:20+00:00

I am decorating my controller actions with an AuthorizeAttribute. [ServiceAuthorize(Roles=Editor,Publisher,Administrator)] public JsonResult Create(NewsArticle newsArticle)

  • 0

I am decorating my controller actions with an AuthorizeAttribute.

[ServiceAuthorize(Roles="Editor,Publisher,Administrator")]
public JsonResult Create(NewsArticle newsArticle)

There is a field in my NewsArticle model that I would like to use in the OnAuthorize method in my AuthorizeAttribute.

Is there any way to get at the model from within the OnAuthorize method of the AuthorizeAttribute?

I assumed it would be available within the AuthorizationContext somewhere but I can’t find it. I know I can get to it in the ActionExecutingContext of a filter attribute but that means I would need another filter on my action and I would like to be able to perform all the authorization in a single step.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:43:21+00:00Added an answer on May 28, 2026 at 2:43 pm

    Is there any way to get at the model from within the OnAuthorize
    method of the AuthorizeAttribute?

    No because the OnAuthorization runs before the model binder. What you could do is to read the value from the value provider:

    public override void OnAuthorization(AuthorizationContext filterContext)
    {
        var value = filterContext.Controller.ValueProvider.GetValue("someproperty");
        ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a practical way to access the attributes decorating a controller or action
I current have the following attribute decorating one of the action method. [Authorize(Roles =
I'm returning a JsonResult from an MVC controller action , and have been trying
Is there any way of decorating a method in .NET with an attribute which
My actions in ASP.NET MVC controller are decorated with numerous properties like this [OutputCache(Duration
I had thought about decorating various control items with attributes to declare group ownership,
What is a simple example of decorating a class by defining the decorator as
With Data Annotations for example, besides decorating members like this: [Required( ErrorMessage = You
Is there a product/project that would allow you to define conventions for say an
How can i create a main page with codeigniter? That page should contain a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.