首页 新闻 会员 周边

MVC中MVC Action方法能有多少重载?

0
悬赏园豆:10 [已解决问题] 解决于 2010-06-28 18:56

是否可以如下有N个重载呢?为什么?

        [AcceptVerbs(HttpVerbs.Get)]
        public ActionResult Index(string Name)
        {
        }

        [AcceptVerbs(HttpVerbs.Get)]
        public ActionResult Index(int Id)
        {
        }
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Index(int n,int a,int b)
        {
   }

Conan的主页 Conan | 初学一级 | 园豆:115
提问于:2010-06-28 16:13
< >
分享
最佳答案
0

不行,这个同名的时候不能重载(可以有一个Get,一个Post)。

试试就知道了,不过自定义Action的名字的时候可以的

 [ActionName("Index2")]

 public ActionResult Index(int n,int a,int b)
        {
   }

收获园豆:10
咒语 | 初学一级 |园豆:192 | 2010-06-28 16:36
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册