mvc - post xml to another site (and redirect to it)
i am using mvc 2 and .net 3.5.
I have 2 mvc si开发者_高级运维tes.
How can i post an xml message from an action/page in site 1 to a page in site 2? And at the same time redirect the user from site 1 to the page in site 2.
thank you very much
Probably the easiest way would be to modify site 2 and add a controller action which would accept an application/x-www-form-urlencoded
request (a.k.a. simple form POST):
<form action="http://site2.com/" method="POST">
<%= Html.HiddenFor(x => x.XmlData) %>
<input type="submit" value="Go to site 2" />
</form>
and on site 2 inside the newly created action which would serve as an entry point you could fetch the XML as a string and process it:
[HttpPost]
[ValidateInput(false)] // <-- that's necessary as we are POSTing XML
public ActionResult Index(string xmlData)
{
// Do something with the posted XML, and redirect or directly render a view
}
精彩评论