Click here to Skip to main content
15,868,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello

I'm calling the post method with the following code. All works are done correctly. The problem is only putting the name of the driver in Persian. to save the databases in unnecessary letters, for example, a sample of this -EJ/ EG1'(J

The problem is not the database and the server side. Because, according to Admin, other people who call their information are right

Thanks for the help of friends if you have any experience in this field.

my code is


What I have tried:

private static string Post(string url)
    {
        string postData = string.Empty;

        HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create(url);

        BinaryFormatter bf = new BinaryFormatter();
        MemoryStream ms = new MemoryStream();
        bf.Serialize(ms, postData);

        byte[] data = ms.ToArray();

        httpWReq.ContentLength = data.Length;

        httpWReq.Method = "POST";
        httpWReq.Headers.Set(HttpRequestHeader.AcceptEncoding, "UTF-8");
        httpWReq.Headers.Set(HttpRequestHeader.AcceptCharset, "UTF-8");
        httpWReq.Headers.Set(HttpRequestHeader.AcceptLanguage, "fa-ir, ar, en"); 

        httpWReq.Headers.Add(HttpRequestHeader.AcceptCharset, "UTF-8");
        httpWReq.Headers.Add(HttpRequestHeader.AcceptEncoding, "UTF-8");
        httpWReq.Headers.Add(HttpRequestHeader.AcceptLanguage, "fa-ir, ar, en");

        httpWReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1);Accept-Language:fa-ir";

        httpWReq.Accept = "application/x-www-form-urlencoded;charset=UTF-8";
        httpWReq.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
        httpWReq.Headers.Add("USER", "62");
        httpWReq.Headers.Add("PASSID", "11111");
        httpWReq.Headers.Add("DRIVER", "علی محمدی");

        byte[] bytes = Encoding.UTF8.GetBytes(postData.ToString());

        using (Stream newStream = httpWReq.GetRequestStream())
        {
            newStream.Write(data, 0, data.Length);
        }

        HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();

        Stream stream = response.GetResponseStream();

        Encoding encode = System.Text.Encoding.GetEncoding("UTF-8");

        StreamReader streamReader = new StreamReader(stream, encode);

        string html = streamReader.ReadToEnd();

        response.Close();

        streamReader.Close();


        return html;
    }
Posted
Updated 25-Jun-19 17:57pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900