SendDataToSites.Post Method

Using POST request to send text data. Example: https://gist.github.com/Zalexanninev15/79b2c80f01f144961ad933d9eeb6b980
public static string Post( 
string url
string options 
)
This language is not supported or no code example is available.

Parameters

url
string

The url.

options
string

The options.

Return Value

string

A string.

public static string Post(string url,
     string options)
 {
     try
     {
         WebRequest req = WebRequest.Create(url);
         req.Method = "POST";
         req.Timeout = 100000;
         req.ContentType = "application/x-www-form-urlencoded";
         byte[] sentData = Encoding.UTF8.GetBytes(options);
         req.ContentLength = sentData.Length;
         Stream sendStream = req.GetRequestStream();
         sendStream.Write(sentData, 0, sentData.Length);
         sendStream.Close();
         WebResponse res = req.GetResponse();
         Stream ReceiveStream = res.GetResponseStream();
         StreamReader sr = new StreamReader(ReceiveStream, Encoding.UTF8);
         char[] read = new char[256];
         int count = sr.Read(read, 0, 256);
         string Out = string.Empty;
         while (count > 0)
         {
             string str = new string(read, 0, count);
             Out += str;
             count = sr.Read(read, 0, 256);
         }
         return Out;
     }
     catch (Exception ex) { return ex.Message; }
 }
					
This language is not supported or no code example is available.

.NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

.NET Core

Supported in: 5.0+, 6.0+

In this article

Definition