I'm trying to send large json string in my c# application to an asp.net page using querystring (POST method), but because the string is too long it give me this msg: Invalid uri: the uri link is too long.
Is there is another solution for my problem !?
if(allRecords.Count > 0)
for (int j = 0; j < allRecords.Count; j++)
{
queryString += JsonConvert.SerializeObject(allRecords[j], Newtonsoft.Json.Formatting.Indented);
}
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(queryString);
// Set up Request.
HttpWebRequest webReq = WebRequest.Create(onlineApp) as HttpWebRequest;
webReq.ContentType = "text/plain";
webReq.Method = "POST";
webReq.Credentials = CredentialCache.DefaultCredentials;
webReq.ContentLength = data.Length;
// Send Request.
Stream newStream = webReq.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
// get Response.
HttpWebResponse response = (HttpWebResponse)webReq.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string tt = reader.ReadToEnd();
reader.Close();
response.Close();