Cranialsurge
Cranialsurge

Reputation: 6184

Post from one ASP.NET MVC site to another

Is it possible to post a form from one MVC site so that it invokes the POST action in a controller on another site ? I can do a GET easily, but a browser redirect is always a GET as per my understanding and I am unable to invoke the target site's POST action.

e.g. http:/siteA.com/test invokes http://siteB.com/result/signin ... in the ResultController, the Get version of the "SignIn" action gets invoked, but I need the "Post" version to be invoked as I need to pass in parameters in the POST header.

Currently I am resorting to using a GET and am passing params. using the query string which is not ideal for my scenario. Any help here would be appreciated.

Upvotes: 1

Views: 2473

Answers (2)

Cranialsurge
Cranialsurge

Reputation: 6184

I used AJAX to invoke the target and bundled in the necessary parameters to post in there.

Upvotes: 1

Darin Dimitrov
Darin Dimitrov

Reputation: 1039438

You could POST using a simple form:

<form method="post" action="http://othersite.com/controller/action">
    <!-- some input fields containing the values to post -->
    <input type="hidden" name="param1" value="value1" />
    <input type="submit" value="Post to other site" />
</form>

Upvotes: 4

Related Questions