开发者

Html.CanvasActionLink generates a POST?

I have this two methods in my controller:

public ActionResult MyMet开发者_开发问答hod()
{
}


[HttpPost]
public ActionResult MyMethod()
{
}

And in the View:

Html.CanvasActionLink("Link", "MyMethod")

When I click the link, the second method is always invoked, it is doing a POST?


In your facebook aplication settings you should disable the setting "Post for canvas"


You can't have those two methods on the same controller because your code simply wont't compile. It is forbidden to have two methods with the same name and same parameters on the same class. You probably have:

public ActionResult MyMethod()
{
}

[HttpPost]
public ActionResult MyMethod(SomeViewModel model)
{
}

So depending on the HTTP verb being used in the request the action invoker will choose the first or the second method. GET request dispatches to the first, POST request will be dispatched to the second.

I am not aware with the CanvasActionLink extension method (it is not standard ASP.NET MVC) but if the second action is invoked it means that it uses POST (either through javascript AJAX or through HTML <form> element).

You could use FireBug to see exactly what's requests are being sent between the client and the server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜