简体   繁体   English

HTTP POST,从ASP .Net重定向到JSP / ColdFusion,哪种方法最好是服务器端或客户端?

[英]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: 要考虑的其他问题:

  1. Client may have JavaScript disabled. 客户端可能禁用了JavaScript。
  2. If the remote server supports SSL, then you should probably be posting to that. 如果远程服务器支持SSL,那么您可能应该发布到SSL。
  3. Doing this client side, you'll be sending all form data to the client initially, and then sending it on to the 3rd party server. 在此客户端,您将首先将所有表单数据发送到客户端,然后将其发送到第三方服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET-如何从响应“重定向”到服务器端进程生成的http帖子的重定向? - ASP.NET - How do I 'follow' a redirect from a response to an http post generated by a server side process? Asp.net。 服务器端验证和客户端验证很好地协同工作的最佳方式是什么 - Asp.net. what’s the best way that server side validation and client side validation work together nicely 从服务器端asp.net注册客户端json的有效方法? - Efficient way to register client-side json from server-side asp.net? 在客户端存储数据的最佳方式 - ASP.Net + JQuery - Best way to store data on the client side - ASP.Net + JQuery 缓存ASP.NET HTTP Handler服务器和客户端的响应 - Caching the response of an ASP.NET HTTP Handler server and client side 在asp.net中从服务器端重定向并传递值 - Redirect and pass a value from server side in asp.net 本地化.NET Web应用程序的最佳方式(服务器端和客户端) - Best way to Localize .NET Web Application (Both Server-Side and Client-Side) 将元素[数据]发布到服务器端的最佳方法 - Best way to post element [data] to server side 从asp.net端向Tally服务器发送Http请求 - Http Request to Tally server from asp.net side 在ASP.net中从服务器端使用参数调用客户端JavaScript - Calling client javascript with params from server side in ASP.net
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM