我正在使用asp.net编写Web应用程序。我通过一些非公开但可供我的服务器端使用的网络连接到JSP页面。我的目标是从我的asp.net页面(将公开)将数据发布到jsp页面(对用户来说是私有的),然后检索jsp.page的答案
protected void Page_Load(object sender, EventArgs e)
{
Page page = HttpContext.Current.Handler as Page;
String Url = "https://192.168.0.1:1111/aaa/sss/test.jsp";
StringBuilder postData = new StringBuilder();
postData.Append("a=" + p.Request.Form[0] + "&");
postData.Append("b=" + p.Request.Form[1] + "&");
postData.Append("c=" + p.Request.Form[2] + "&");
postData.Append("d=" + p.Request.Form[3] + "&");
postData.Append("e=" + p.Request.Form[4] + "&");
postData.Append("f=" + p.Request.Form[5] + "&");
postData.Append("g=" + p.Request.Form[6] + "&");
postData.Append("h=" + p.Request.Form[7]);
StreamWriter writer = null;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url);
request.Method = "POST";
request.ContentType = "text/html";
request.ContentLength = postData.ToString().Length;
try
{
writer = new StreamWriter(request.GetRequestStream());
writer.Write(postData.ToString());
System.Web.HttpContext.Current.Response.Write(writer.ToString());
}
finally
{
if (writer != null)
writer.Close();
}
}
答案 0 :(得分:0)
@LuiggiMendosa但是当我检查结果时,我知道该页面已经工作,因为我说页面已经完成了它的工作只有我没有收到响应,我的应用程序收到上述错误 当我更改HttpRequestHeader.ContentType时,页面没有做任何事情。