2016-04-21 45 views
0

我知道我已经做到这一点,它的工作,但今天当我创造了我的控制器两种方法和我得到..ASP.NET MVC暧昧的动作方法的签名和不同使用GET/POST

采取行动的当前请求“联系我们”上控制器类型“的HomeController”是以下动作的方法之间暧昧:

System.Web.Mvc.ActionResult联系我们()上式的HomeController System.Web.Mvc.ActionResult联系我们(联系人)在类型HomeController上。

这是我的两个不同的两个post/get。

<HttpGet> 
Function ContactUs() As ActionResult 
Dim objModel As New ContactUsModel 

    Return View(objModel) 
End Function 

<HttpPost> 
Function ContactUs(ByVal Model As ContactUs) As ActionResult 
    Dim a As String = "" 
    Return View(Model) 
End Function 

我不明白的是,这些可能是不明确的,因为他们有不同的签名,并用post/get装饰。

+0

在什么情况下你会得到这个异常? – Andrei

+0

如果我只是尝试访问/ home/contactus的页面,我会收到错误消息。如果我删除第二种方法(后),页面加载罚款。 –

+2

请确保您使用的是MVC属性btw,因为具有完全相同名称的属性存在于'System.Web.Http'命名空间下。一旦你需要在'System.Web.Mvc'中 – Andrei

回答

0

安德烈有解决方案。出于某种原因,它使用System.web httppost和httpget。所以我不得不用装饰每种方法..

<System.Web.Mvc.HttpPost>