Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Response.Redirect which POSTs data to another URL in ASP.NET

I want to redirect a response to another URL while it contains some POST data in it's HTTP header.

// Inside an ASP.NET page code behind:
Response.Redirect("http://www.example.com/?data=sent%20via%20GET");
// This will sent data to http://www.example.com via GET.
// I want to POST this data to http://www.example.com instead.

How to do this in ASP.NET?

like image 910
Xaqron Avatar asked May 19 '11 16:05

Xaqron


People also ask

What is the difference between response redirect () and server transfer ()?

Response. Redirect simply sends a message (HTTP 302) down to the browser. Server. Transfer happens without the browser knowing anything, the browser request a page, but the server returns the content of another.

What is the use of response redirect ()?

Response. Redirect sends an HTTP request to the browser, then the browser sends that request to the web server, then the web server delivers a response to the web browser. For example, suppose you are on the web page "UserRegister. aspx" page and it has a button that redirects you to the "UserDetail.

How can I transfer data from one website to another in asp net?

To post an ASP.NET Web page to another pageAdd a button control to your Web page, such as a Button, LinkButton, or ImageButton control. Set the PostBackUrl property for the control to the URL of the page to which you want to post the ASP.NET Web page.


1 Answers

you can send huge data also with this trick..

Response.Clear();

StringBuilder sb = new StringBuilder();
sb.Append("<html>");
sb.AppendFormat(@"<body onload='document.forms[""form""].submit()'>");
sb.AppendFormat("<form name='form' action='{0}' method='post'>",postbackUrl);
sb.AppendFormat("<input type='hidden' name='id' value='{0}'>", id);
// Other params go here
sb.Append("</form>");
sb.Append("</body>");
sb.Append("</html>");

Response.Write(sb.ToString());

Response.End();
like image 56
Govind Malviya Avatar answered Sep 28 '22 03:09

Govind Malviya