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 763421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:33:26+00:00 2026-05-14T16:33:26+00:00

On a recent question about MVC attributes, someone asked whether using HttpPost and HttpDelete

  • 0

On a recent question about MVC attributes, someone asked whether using HttpPost and HttpDelete attributes on an action method would result in either request type being allowed or no requests being allowed (since it can’t be both a Post and a Delete at the same time). I noticed that ActionMethodSelectorAttribute, from which HttpPostAttribute and HttpDeleteAttribute both derive is decorated with

[AttributeUsage(AttributeTargets.Method,
                AllowMultiple = false,
                Inherited = true)]

I had expected it to not allow both HttpPost and HttpDelete on the same method because of this, but the compiler doesn’t complain. My limited testing tells me that the attribute usage on the base class is simply ignored. AllowMultiple seemingly only disallows two of the same attribute from being applied to a method/class and doesn’t seem to consider whether those attributes derive from the same class which is configured to not allow multiples. Moreover, the attribute usage on the base class doesn’t even preclude your from changing the attribute usage on a derived class. That being the case, what’s the point of even setting the values on the base attribute class? Is it just advisory or am I missing something fundamental in how they work?

FYI – it turns out that using both basically precludes that method from ever being considered. The attributes are evaluated independently and one of them will always indicate that the method is not valid for the request since it can’t simultaneously be both a Post and a Delete.

  • 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-14T16:33:27+00:00Added an answer on May 14, 2026 at 4:33 pm

    Setting AllowMultiple on a base attribute essentially sets a default for all attributes that derive from it. If you wanted all attributes deriving from a base atribute to allow multiple instances then you can save duplication by applying an [AttributeUsage] attribute to this effect to the base attribute avoiding the need to do the same to all the derived attributes.

    For example, suppose you wanted to allow this:

    public abstract class MyAttributeBase : Attribute
    {
    }
    
    public sealed class FooAttribute : MyAttributeBase
    {
    }
    
    public sealed class BarAttribute : MyAttributeBase
    {
    }
    
    [Foo]
    [Foo]
    [Bar]
    [Bar]
    public class A
    {
    }
    

    As it stands, this generates a compiler error since custom attributes, by default, do not permit multiple instances. Now, you could apply an [AttribteUsage] to both [Foo] and [Bar] like this:

    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
    public sealed class FooAttribute : MyAttributeBase
    {
    }
    
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
    public sealed class BarAttribute : MyAttributeBase
    {
    }
    

    But alternatively, you could instead just apply it to the base attribute:

    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
    public abstract class MyAttributeBase : Attribute
    {
    }
    
    public sealed class FooAttribute : MyAttributeBase
    {
    }
    
    public sealed class BarAttribute : MyAttributeBase
    {
    }
    

    Both approaches have the same direct effect (multiple instances of both [Foo] and [Bar] are permitted) but the second approach also has the indirect effect that any other attributes deriving from [MyAttribute] will now allow multiple instances unless they have their own [AttributeUsage] that overrides that setting.

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

Sidebar

Ask A Question

Stats

  • Questions 514k
  • Answers 514k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Do you have more than one project in your solution?… May 16, 2026 at 6:09 pm
  • Editorial Team
    Editorial Team added an answer In my program, I create the $view as an empty… May 16, 2026 at 6:09 pm
  • Editorial Team
    Editorial Team added an answer This should do the trick: Image img = null; using… May 16, 2026 at 6:09 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

In a recent question posed here: ASP.NET MVC: Is Data Annotation Validation Enough? ...it
I need to solicit feedback about a recent security policy change at an organization
I am fairly new at using the ASP.NET MVC framework and was hoping that
At a recent interview, I was asked: Open source web app (say built on
I'm building an asp.net MVC application where users can attach a picture to their
Does anyone have an example of buddy classes in ASP.NET MVC 2 Preview 1?
I've been paying some attention to Microsoft's fairly recent promoting of Velocity as a
And what do you put in your View? A recent blog from Scott Hanselman
I have a problem with the understanding MVC architecture. It's not that I don't
I have been thinking about the best way to calculate the amount of on-hand

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.