I need to POST data to a url in the middle of a script.
process.asp: I need to PO
Use the class described here. This is a pretty good method and I use it all the time:
http://www.jigar.net/articles/viewhtmlcontent78.aspx
public class RemotePost{
private System.Collections.Specialized.NameValueCollection Inputs
= new System.Collections.Specialized.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(){
System.Web.HttpContext.Current.Response.Clear() ;
System.Web.HttpContext.Current.Response.Write( "" ) ;
System.Web.HttpContext.Current.Response.Write( string .Format( "" ,FormName)) ;
System.Web.HttpContext.Current.Response.Write( string .Format( "" ) ;
System.Web.HttpContext.Current.Response.Write( "" ) ;
System.Web.HttpContext.Current.Response.End() ;
}
}
Use it like:
RemotePost myremotepost = new RemotePost() ;
myremotepost.Url = "http://www.jigar.net/demo/HttpRequestDemoServer.aspx" ;
myremotepost.Add( "field1" , "Huckleberry" ) ;
myremotepost.Add( "field2" , "Finn" ) ;
myremotepost.Post() ;