C#中关于超链接中中文编码和解码(UrlEncode,UrlDecode)

利用URL中传长中文的地方

选择用HttpUtility.UrlEncode来进行编码,HttpUtility.UrlEncode来解码,方便且安全

实验:

Default.aspx页

HyperLink1.NavigateUrl = "~/test/Default2.aspx?id=" + HttpUtility.UrlEncode("这里是北京");

Default2.aspx页

string value = Request.QueryString["id"];
Response.Write(HttpUtility.UrlDecode(value));

你可能感兴趣的:(C++,c,C#)