skip to Main Content

i have a table in ms-access database

i create DataTable using select query

then convert DataTable to json and then i compress json because raw json size is 13mb

now i want to send this compressed json to webserver

windows from application side

public string webPostMethod() {

  string URL = "https://mywebsite.com/Default.aspx/SendSaleJson";

  var theWebRequest = HttpWebRequest.Create(URL);
  theWebRequest.Method = "POST";
  theWebRequest.ContentType = "application/json; charset=utf-8";
  theWebRequest.Headers.Add(HttpRequestHeader.Pragma, "no-cache");

  using(var writer = theWebRequest.GetRequestStream()) {

    // i want to send this string ZipJson to webserver
    string ZipJson = "cAMAAB+LCAAAAAAABACdkV9LwzAUxb9K6fM2mtQg7VuWpBrWJTWJaBEpZRsIOhlu+iJ+d2/6b26ojJW+nHPvPfe2v4fPUBsuTKV0mIYoHHWSUyfAiNCYbt7GGAcIp1EEb0DnQ5OTc9+EUBqRlFy0JXstM1e5svAlu3pZLXbgOjrNxX7JHZXOL6VNABhKVzqrCmGsVq1TGM0rpnmzgfQGF5aBwXTOA6azTAio3Liyy7UUtpj2dhTHkzgGk4G+0qZs5vxIYAVzEhb5u+79ZVAqQdG5vlVumI32jw8Xyply/w2FkcoJ3o1OZZ43QvVnDI2L9+2ueq3XK9BJl4ov+0K9XDb/cOjcPIHe1uuP+rmP+pfG1+iAIT6XIQGMyYkM8RkMUXIEUQdGMhEwQ9lMmIEjOeaYTCJyiHFqBJ1l1Lq/CSZkgskhNHwqNHwE7Qec32m1+gRUj98dKmcYcAMAAA==";
    string send = null;
    send = "{"value":"test"}";

    var data = Encoding.ASCII.GetBytes(send);

    writer.Write(data, 0, data.Length);
  }

  var theWebResponse = (HttpWebResponse) theWebRequest.GetResponse();
  var theResponseStream = new StreamReader(theWebResponse.GetResponseStream());

  string result = theResponseStream.ReadToEnd();
  return result;

}

asp.net server side

[WebMethod()]
    public static string Senddata(string value)
    {
        return "data Received: " + value;
    }

This code is working fine but i can’t send ZipJson string to server.

2

Answers


  1. You only declare the ‘ZipJson’ string but didn’t use or send it. You have to pass that string to the web server.

    Login or Signup to reply.
  2. Did you try to use Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 instead of "application/json; charset=utf-8";

    Or use your zip data as json string like this:

    send = "{"value":"test", "zipdata" : "YOUR STRING"}";

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search