Can you overload controller methods in ASP.NET MVC?

前端 未结 17 2033
无人共我
无人共我 2020-11-22 08:10

I\'m curious to see if you can overload controller methods in ASP.NET MVC. Whenever I try, I get the error below. The two methods accept different arguments. Is this some

17条回答
  •  青春惊慌失措
    2020-11-22 08:54

    To overcome this problem you can write an ActionMethodSelectorAttribute that examines the MethodInfo for each action and compares it to the posted Form values and then rejects any method for which the form values don't match (excluding the button name, of course).

    Here's an example:- http://blog.abodit.com/2010/02/asp-net-mvc-ambiguous-match/

    BUT, this isn't a good idea.

提交回复
热议问题