开发者

HTTP POST, Redirect from ASP .Net to JSP/ColdFusion which way is best Server Side or Client Side?

开发者 https://www.devze.com 2022-12-18 04:49 出处:网络
I want to post data to another server (JSP or ColdFusion). Note: Post which means the data is required at the another server also the browser should be redirected automatically.

I want to post data to another server (JSP or 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

form.submit();

or

HttpWebRequest myRequest =
        (HttpWebRequest)WebRequest.Create("http://...");

        myRequest.CookieContainer = new System.Net.CookieContainer(10000);
        myRequest.Method = "POST";
        myRequest.ContentType = "a开发者_高级运维pplication/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?

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.

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).

The other issues to consider:

  1. Client may have JavaScript disabled.
  2. If the remote server supports SSL, then you should probably be posting to that.
  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.
0

精彩评论

暂无评论...
验证码 换一张
取 消