Solution 2:
Use this class from an example website to dynamically generate the form page and submit it.
filename: ~/App_Code/RemotePost.cs
using System.Collections.Specialized;
using System.Web;
/* Usage example
* From: http://www.jigar.net/articles/viewhtmlcontent78.aspx
*
RemotePost myremotepost = new RemotePost();
myremotepost.Url = "http://www.jigar.net/demo/HttpRequestDemoServer.aspx";
myremotepost.Add("field1", "Huckleberry");
myremotepost.Add("field2", "Finn");
myremotepost.Post();
* */
/// <summary>
/// Summary description for RemotePost
/// </summary>
public class RemotePost
{
private NameValueCollection Inputs = new NameValueCollection();
public string Url = "";
public string Method = "post";
public string FormName = "form1";
public void Add(string name, string value)
{
Inputs.Add(name, value);
}
public void Post()
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Write("<html><head>");
HttpContext.Current.Response.Write(string.Format("</head><body onload=\"document.{0}.submit()\">", FormName));
HttpContext.Current.Response.Write(string.Format("<form name=\"{0}\" method=\"{1}\" action=\"{2}\" >", FormName, Method, Url));
for (int i = 0; i < Inputs.Keys.Count; i++)
{
HttpContext.Current.Response.Write(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">", Inputs.Keys[i], Inputs[Inputs.Keys[i]]));
}
HttpContext.Current.Response.Write("</form>");
HttpContext.Current.Response.Write("</body></html>");
HttpContext.Current.Response.End();
}
}