[英]HTTP POST, Redirect from ASP .Net to JSP/ColdFusion which way is best Server Side or Client Side?
I want to post data to another server (JSP or ColdFusion). 我想将数据发布到另一台服务器(JSP或ColdFusion)。 Note: Post which means the data is required at the another server also the browser should be redirected automatically. 注意:发布表示这是另一台服务器上需要的数据,并且浏览器应自动重定向。
Is it better to use form tag...input type hidden fields, values ... and from javascript 最好使用表单标签...输入类型的隐藏字段,值...以及从javascript中获取
form.submit(); form.submit();
or 要么
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("http://...");
myRequest.CookieContainer = new System.Net.CookieContainer(10000);
myRequest.Method = "POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream = myRequest.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
return myRequest;
or 要么
I should use WebClient class? 我应该使用WebClient类吗?
Please provide the points from Security view also. 请同时从“安全性”视图中提供要点。
If you want the browser to be correctly sent to the other server, then you should really do this client side - your second option will send the response from the remote server back down to the client, but any links in the HTML that are relative will appear broken, as the user will be attempting to request them from your server. 如果您希望浏览器正确地发送到另一台服务器,那么您应该真正在客户端执行此操作-您的第二个选项将把来自远程服务器的响应发送回客户端,但是HTML中相对的任何链接都将似乎已损坏,因为用户将尝试从您的服务器请求它们。
Also, making the request from the code-behind, you'll be sending the request from your server, without any of the client's cookies, headers, etc for that site (which you won't have access to). 同样,从后面的代码发出请求,您将从服务器发送请求,而没有该站点的任何客户端cookie,标头等(您将无法访问)。
The other issues to consider: 要考虑的其他问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.