rezajon_silver Ответов: 0

Не работает персидский шрифт в методе post веб-служб restful


Привет

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


Что я уже пробовал:

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;
    }

0 Ответов