首页 新闻 会员 周边

MVC 控制器特性反射遇到Ambiguous match found问题

0
悬赏园豆:5 [已解决问题] 解决于 2011-12-22 15:16

通知我们在写控制器的时候会这样写:即2个方法同名,但参数不同.在每个方法上应用了自定义的特性.

[myattr(data="beijing"]
public ActionResult About()
{
return View();
}


[myattr(data="beijing"]
[HttpPost]
public ActionResult About(string id)
{
return View();
}

正是由于这样,在反射时得到此特性时,出现Ambiguous match found错误:

var method = this.GetType().GetMethod("About")

但是,由于About只是其中的方法之一,以后有可能其它的方法也会有类似的写法,参数类型,数量也不一致.

请问一下,我应该如何写才能排除这个错误呢?

mvc
问题补充:

添加问题的附件:

http://files.cnblogs.com/denni/MVC-ActionMethodSelectorAttrib.rar

denli的主页 denli | 初学一级 | 园豆:19
提问于:2011-12-21 11:59
< >
分享
最佳答案
0

ActionMethodSelectorAttribute

收获园豆:5
水牛刀刀 | 大侠五级 |园豆:6350 | 2011-12-21 14:33
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册