js中文编码到C#后台解码

传递中文之前,将要传递的中文参数进行编码,在接收时再进行解码。

1、C#代码

>> 进行传递

string Name = "中文参数";

Response.Redirect("B.aspx?Name="+Server.UrlEncode(Name));

>> 进行接收

string Name = Request.QueryString["Name"];

Response.Write(Server.UrlDecode(Name));

2、JS代码和C#代码

>> 进行传递

<script language="JavaScript">

function GoUrl()

{

var Name = "中文参数";

location.href = "B.aspx?Name="+escape(Name);

}

</script>

<body onclick="GoUrl()">

>> 进行接收

string Name = Request.QueryString["Name"];

Response.Write(Server.UrlDecode(Name));

原文地址:https://www.cnblogs.com/zk-zhou/p/6496243.html