Created
October 25, 2013 23:32
-
-
Save priore/7163408 to your computer and use it in GitHub Desktop.
ASP.NET [C#] Redirect with post data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Web; | |
using System.Collections.Specialized; | |
using System.Text; | |
// ASP.NET [C#] REDIRECT WITH POST DATA | |
public static class WebExtensions | |
{ | |
public static void RedirectWithData(NameValueCollection data, string url) | |
{ | |
HttpResponse response = HttpContext.Current.Response; | |
response.Clear(); | |
StringBuilder s = new StringBuilder(); | |
s.Append("<html>"); | |
s.AppendFormat("<body onload='document.forms[\"form\"].submit()'>"); | |
s.AppendFormat("<form name='form' action='{0}' method='post'>", url); | |
foreach (string key in data) | |
{ | |
s.AppendFormat("<input type='hidden' name='{0}' value='{1}' />", key, data[key]); | |
} | |
s.Append("</form></body></html>"); | |
response.Write(s.ToString()); | |
response.End(); | |
} | |
} |
Thank you so much. I search this code from a month. Thanks a lot.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Good to know @rockybalog please help me when your find time. Thanks in advance