Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Thursday, September 25, 2008

How To Post Data From ASP.net To Another URL






using System;
using System.Net;
using System.Web;
using System.Collections.Specialized;


public class RemotePost
{
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("");
HttpContext.Current.Response.Write(string.Format("", FormName));
HttpContext.Current.Response.Write(string.Format("
", FormName, Method, Url));
int i = 0;
while (i < Inputs.Keys.Count)
{
HttpContext.Current.Response.Write(string.Format("", Inputs.Keys[i],Inputs.Keys[i]));
i += 1;
}
HttpContext.Current.Response.Write(""
);
HttpContext.Current.Response.Write("");
HttpContext.Current.Response.End();
}
}


<%@ Page Language="C#" %>

"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



"http://www.w3.org/1999/xhtml">
"server">
Untitled Page


"form1" runat="server">

"Button1" runat="server" OnClick="Button1_Click" Text="Post Data To Another Application" />






<%@ Page Language="C#" %>

"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



"http://www.w3.org/1999/xhtml" >
"server">
Untitled Page


"form1" runat="server">





0 comments:

Post a Comment

Archives