using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Net;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
//https://www.aspsnippets.com/Articles/How-to-transfer-data-from-one-website-to-another-in-ASPNet.aspx
protected void Button1_Click(object sender, EventArgs e)
{
//string remoteUrl = "http://localhost:54358/PostDataFromOneWebsiteToAnother/Page2_CS.aspx";
string remoteUrl = "http://localhost:12924/Dengue/getApi.aspx";
string firstName = "Varun";
string lastName = "Sharma";
ASCIIEncoding encoding = new ASCIIEncoding();
string data = string.Format("FirstName={0}&LastName={1}", firstName, lastName);
byte[] bytes = encoding.GetBytes(data);
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(remoteUrl);
httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";
httpRequest.ContentLength = bytes.Length;
using (Stream stream = httpRequest.GetRequestStream())
{
stream.Write(bytes, 0, bytes.Length);
stream.Close();
}
}
}
---------------------------------------------------------------
here I am fetching data but not able to show in textbox
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class getApi : System.Web.UI.Page
{
string firstName;
string lastName;
protected void Page_Load(object sender, EventArgs e)
{
txtLname.Text = Request.Form["FirstName"];
//lastName = Request.Form["LastName"];
}
}