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

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();

Why do I get “Cannot redirect after HTTP headers have been sent” when I call Response.Redirect()?

According to the MSDN documentation for Response.Redirect(string url), it will throw an HttpException when “a redirection is attempted after the HTTP headers have been sent”. Since Response.Redirect(string url) uses the Http “Location” response header (http://en.wikipedia.org/wiki/HTTP_headers#Responses), calling it will cause the headers to be sent to the client. This means that if you call it a … Read more

Response.Redirect to new window

I just found the answer and it works 🙂 You need to add the following to your server side link/button: OnClientClick=”aspnetForm.target=”_blank”;” My entire button code looks something like: <asp:LinkButton ID=”myButton” runat=”server” Text=”Click Me!” OnClick=”myButton_Click” OnClientClick=”aspnetForm.target=”_blank”;”/> In the server side OnClick I do a Response.Redirect(“MyPage.aspx”); and the page is opened in a new window. The other … Read more