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

  • Home
  • SEARCH
  • 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 3456806
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:46:57+00:00 2026-05-18T09:46:57+00:00

If I decorate a controller action with a custom ActionMethodSelectorAttribute, the attribute is evaluated

  • 0

If I decorate a controller action with a custom ActionMethodSelectorAttribute, the attribute is evaluated during standard use and I can break in the attribute’s body during a debug session. However, the attribute is not assessed / evaluated when the controller action is called during a unit test, nor will it break during debug. Why is this? Surely behaviour should be identical whether running normally or under test?

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-18T09:46:57+00:00Added an answer on May 18, 2026 at 9:46 am

    It’s the ASP.NET MVC framework that’s responsible for running action filters. Internally, it’s using reflection to inspect the controller and action method, and if the method or controller are decorated with any ActionFilter attributes, it’ll run those filters at the appropriate point in the request lifecycle.

    For unit testing, you’ll want to unit-test your action filters separately – inject a mocked ActionExecutedContext (or whichever context you’re filtering) into the filter method directly, and verify that the route / result / viewdata are modified as required.

    If you’re really committed to 100% test coverage, you can also implement unit tests that’ll use reflection to verify that you’ve got the required action filter attributes decorating the appropriate controller methods.

    Don’t worry about tests to make sure the action filters are fired – those tests are part of the ASP.NET MVC source code and last time I looked, they were all green.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to decorate/extend the python standard logging system, so that when a
In C#, is it possible to decorate an Enum type with an attribute or
When employing custom attributes to store meta-data, is it best to decorate the interface,
My Controller class is decorated with an AuthorizeAttribute to protect the actions: [Authorize(Roles =
I have a really simple Java class that effectively decorates a Map with input

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.