网页浏览器使用的网址编码是什么? [英] What url encoding web browser uses?

查看:790
本文介绍了网页浏览器使用的网址编码是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在向服务器提交数据时,网络浏览器使用哪种网址编码?使用我的应用程序
我使用 HttpUtility.UrlEncode(字符串数据)
但是没有得到我用网络浏览器得到的结果。



我的应用程序向论坛提交了一些文本数据。



当我使用网络浏览器(谷歌浏览器)提交数据时,确切的文字我可以看到提交到服务器,但是当我使用我的应用程序提交它时显示一些不同的字符。



那么提交任何数据到服务器必须进行url编码吗? / p>

---编辑---

  data = HttpUtility.UrlEncode(textBox1.Text); 

HttpWebRequest request =(HttpWebRequest)WebRequest.Create(url);
request.CookieContainer = cookieContainer;
request.UserAgent =Mozilla / 5.0(Windows NT 6.1; WOW64)AppleWebKit / 536.5(KHTML,如Gecko)Chrome / 19.0.1084.56 Safari / 536.5;
request.Accept =text / html,application / xhtml + xml,application / xml; q = 0.9,* / *; q = 0.8;
request.Headers.Add(Accept-Charset,ISO-8859-2,utf-8; q = 0.7,*; q = 0.7);
request.Headers.Add(Accept-Encoding,gzip,deflate);
request.Headers.Add(Accept-Language,pl,en-us; q = 0.7,en; q = 0.3);
request.Method =POST;
byte [] byteArray = new byte [256];
ASCIIEncoding ascii = new ASCIIEncoding();
byteArray = ascii.GetBytes(data);

request.ContentType =application / x-www-form-urlencoded;
request.ContentLength = byteArray.Length;
流dataStream = request.GetRequestStream();
dataStream.Write(byteArray,0,byteArray.Length);
dataStream.Close();

和textbox1中的数据是这样的。

  | = | = || = | = | 
RUNTIME ......... ..:2h:13m:15s
RELEASE SIZE ......:16,2GB
VIDEO CODEC ......:x264,2pass,


解决方案

如果你想在url参数中包含一个URL保留的charatcer(?,&等),你通常只需要URLEncode。


What url encoding a web browser uses while submitting data to server? with my application i use HttpUtility.UrlEncode(string data) but do not get result as i get with web browser.

My application submit some text data to forum.

When i am submitting data with web browser (Google Chrome) the exact text i can see submitted to server but when i am submitting using my application it showing some character different.

So is this necessary to submit any data to server must be url encoded?

---Edit---

        data = HttpUtility.UrlEncode(textBox1.Text);

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
        request.CookieContainer = cookieContainer;
        request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5";
        request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
        request.Headers.Add("Accept-Charset", "ISO-8859-2,utf-8;q=0.7,*;q=0.7");
        request.Headers.Add("Accept-Encoding", "gzip, deflate");
        request.Headers.Add("Accept-Language", "pl,en-us;q=0.7,en;q=0.3");
        request.Method = "POST";
        byte[] byteArray = new byte[256];
        ASCIIEncoding ascii = new ASCIIEncoding();
        byteArray = ascii.GetBytes(data);     

        request.ContentType = "application/x-www-form-urlencoded";
        request.ContentLength = byteArray.Length;
        Stream dataStream = request.GetRequestStream();
        dataStream.Write(byteArray, 0, byteArray.Length);
        dataStream.Close();

and data in textbox1 is like this.

¦=¦=¦¦=¦=¦
RUNTIME………..: 2h:13m:15s
RELEASE SIZE……: 16,2GB
VIDEO CODEC…….: x264, 2pass,

解决方案

You generally only have to URLEncode if you want to include a URL reserved charatcer (?, &, etc.) in a url parameter.

这篇关于网页浏览器使用的网址编码是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆