Thakur Adarsh Singh
Thakur Adarsh Singh

Reputation: 21

How to call httppost action from ActionLink

@Html.ActionLink("PostActionName","MyController")

Here I want to call PostActionName which having HttpPost Verb. Currentlly i am not able to call PostActionName. It only calling HttpGet verb Action.

Upvotes: 1

Views: 395

Answers (1)

Omprakash tomar
Omprakash tomar

Reputation: 51

You can't call POST Action method using @Html.ActionLink, instead you can use @Ajax.ActionLink to call a POST action method. Firstly you need Scripts

<script src="∼/Scripts/jquery-1.10.2.js"></script>
<script src="∼/Scripts/jquery.unobtrusive-ajax.js"></script>

 @Ajax.ActionLink("Action Name", "PostActionName", new AjaxOptions { HttpMethod = "Post"})

Upvotes: 1

Related Questions