读书人

.ashx接收参数出现乱码有关问题.等解决

发布时间: 2013-08-26 12:17:40 作者: rapoo

.ashx接收参数出现乱码问题...急等解决!!!
.ashx后台:

 
public void ProcessRequest(HttpContext context)
{

context.Request.ContentEncoding = Encoding.GetEncoding("gb2312");
context.Response.ContentType = "text/plain";
if (context.Request.Form["_type"] != null)
{
switch (context.Request.Form["_type"])
{
case "_AllPageNum": SendAllPageNum(context); break;
default: break;
}
}
}


private void SendAllPageNum(HttpContext context)
{
string TableName = context.Request.Form["_TableName"];
string SelectWhere = context.Request.Form["_SelectWhere"]; }


string SelectWhere = context.Request.Form["_SelectWhere"] 页面输入的是汉字,但是传过来
就成了乱码le
------解决方案--------------------


传的时候编码 HttpUtility.UrlEncode
接受的时候解码 HttpUtility.UrlDecode
[解决办法]

引用:
传的时候编码 HttpUtility.UrlEncode
接受的时候解码 HttpUtility.UrlDecode

+1

读书人网 >asp.net

热点推荐