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). 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:
- Client may have JavaScript disabled.
- If the remote server supports SSL, then you should probably be posting to that.
- 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.
精彩评论