这可能不是最佳解决方案,但要求是将请求正文中的某些数据发布到另一个应用程序,以便接收应用程序可以读取数据并根据发布的数据执行操作。我想将数据从a.mydomain.com/PostData发布到b.mydomain.com/RequestData,其中RequestData的返回类型为IACtionResult,根据所发布的数据在应用程序B上呈现视图。这可能吗。
我创建了一个Web请求,并使用GetRequestStream()创建了正文,在创建正文之后,我想重定向到b.mydomain.com/RequestData,在这里我可以读取请求正文并呈现我的视图< / p>
WebRequest request = WebRequest.Create("http://b.mydomain.com/RequestData");
// Set the Method property of the request to POST.
request.Method = "POST";
// Create POST data and convert it to a byte array.
string postData = "This is a test that posts this string to a Web server.";
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
// Set the ContentType property of the WebRequest.
request.ContentType = "application/x-www-form-urlencoded";
// Set the ContentLength property of the WebRequest.
request.ContentLength = byteArray.Length;`enter code here`
// Get the request stream.
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();