1

I got the value of text box from view to one of my action in the controller. Now I need to send this value to post method of some other action which takes model values as its parameter. The action where I got the value from controller :

public ActionResult Track(string txtEmployeeNo)
    {
        ReporteesInboxModel objTrackRequestModel1 = new ReporteesInboxModel();
        objTrackRequestModel1.strempno = txtEmployeeNo;

        return RedirectToAction("TrackRequest", new { objTrackRequestModel = objTrackRequestModel1, ActionStatus = "" });
    }

I need to redirect it to:

[HttpPost]
public ActionResult TrackRequest(ReporteesInboxModel objTrackRequestModel, string ActionStatus)
{
......
}

but the line :

return RedirectToAction("TrackRequest", new { objTrackRequestModel = objTrackRequestModel1, ActionStatus = "" }); 

redirects me to the GET method and not the post method.

krypru
  • 1,692
  • 3
  • 22
  • 29
  • 1
    `RedirectToAction()` is always to a GET –  Dec 19 '16 at 04:49
  • 2
    Why you need to do that? Just post it from client side. – SᴇM Dec 19 '16 at 05:11
  • Actually, you can't redirect using post method. Please refer to these questions. [question 1](http://stackoverflow.com/questions/10286382/how-to-redirect-asp-net-mvc-with-a-post) [question 2](http://stackoverflow.com/questions/16643414/asp-net-mvc-redirecttoaction-with-parameters-to-post-action) they are also trying to achieve the same thing. – R K Sharma Dec 19 '16 at 05:52
  • `RedirectToAction` only points to method using `HttpGet`, hence you need a POST request either using form submit or AJAX call. Returning view to perform POST request is more preferred than redirection. – Tetsuya Yamamoto Dec 19 '16 at 08:50

0 Answers0