Reputation: 14316
How can I redirect from a controller to an external URL using POST method and passing some parameters?
Basically I need to do automatically what a form would do.
I found Redirect method in my controller, but it only seems to accept a url string. No method nor parameters.
Upvotes: 4
Views: 8469
Reputation: 106
I'm using Fluentx.Mvc from Nuget for this.
Install Fluentx.Mvc from nuget
You need to include in your code:
using Fluentx.Mvc;
and the code to call a external URL with post:
First create a Dictionary like:
Dictionary<string, object>
objData = new Dictionary<string, object>();
and insert values:
objData.Add("name", "John");
objData.Add("city", "NY");
After that, use return from Fluentx:
return this.RedirectAndPost("http://yourexternalurl", objData);
In your external url, you get values :
string strName = Request["nome"];
string strCity = Request["city"];
Upvotes: 4
Reputation: 100620
You can't do post with server side redirect. Options:
Upvotes: 2