我有3個重載控制器的創建方法:解決歧義
public ActionResult Create() {}
public ActionResult Create(string Skill, int ProductId) {}
public ActionResult Create(Skill Skill, Component Comp) {}
在我的意見就是我想要創建這個事情,所以我把它稱爲是這樣的:
<div id="X">
@Html.Action("Create")
</div>
但我得到錯誤:
{"The current request for action 'Create' on controller type 'XController' is ambiguous between the following action methods: System.Web.Mvc.ActionResult Create() on type X.Web.Controllers.XController System.Web.Mvc.ActionResult Create(System.String, Int32) on type X.Web.Controllers.XController System.Web.Mvc.ActionResult Create(X.Web.Models.Skill, X.Web.Models.Component) on type X.Web.Controllers.XController"}
但由於@html.Action()
沒有傳遞參數,所以應該使用第一個重載。它對我來說似乎並不明確(這隻意味着我不認爲像C#編譯器)。
任何人都可以指出我的方式的錯誤?
是的,我看到......感謝您的認真回覆。你得到一個點:) – ekkis
歡迎您:D ans謝謝接受答案 –
恥辱鏈接的問題被刪除。 7536119/mvc3-routing-with-overloaded-query-parameters – Maggie