Post Data on URL using Asp.net C#
Post Data on URL using Asp.net C
C# code :
private void PostForm()
{
string remoteUrl = "Posted_Url";
string MobileNo = "11";
string EmailId = "11";
string Registrationno = "11";
string PackageName = "11";
string ExpiryDate = "1-12-2017";
string TransactionId = "11";
string memberCode = "11";
string CoverageDetails = "11";
string Status = "11";
string PartnerName = "11";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(remoteUrl);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
string postData = string.Format("MobileNo={0}&EmailId={1}&Registrationno={2}&PackageName={3}&ExpiryDate={4}&TransactionId={5}&memberCode={6}&CoverageDetails={7}&Status={8}&PartnerName={9}", MobileNo, EmailId, Registrationno, PackageName,
ExpiryDate, TransactionId, memberCode, CoverageDetails, Status, PartnerName);
byte[] bytes = Encoding.UTF8.GetBytes(postData);
request.ContentLength =
bytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0,
bytes.Length);
WebResponse response = request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader reader = new StreamReader(stream);
var result = reader.ReadToEnd();
stream.Dispose();
reader.Dispose();
}
Comments
Post a Comment