Let's go

一般处理程序解决中文入参乱码问题

 1、首先,js中,进行URL编码(使用escape)

 2、一般处理程序或.ASPX接收页面进行接收参数并解码,使用(context.Server.UrlDecode)

//学年
string strSchoolYear = context.Server.UrlDecode(context.Request.QueryString["SchoolYear"]);
//学期
string strSemester = context.Server.UrlDecode(context.Request.QueryString["Semester"]);
    LogHelp logHelp = new LogHelp();//日志记录帮助类
    public void ProcessRequest(HttpContext context)
    {

        context.Request.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
        //邮件信息
        returnMail data = null;
        JavaScriptSerializer js = new JavaScriptSerializer();
        logHelp.WriteLog("接受参数成功,mailObj==>" + context.Request.QueryString["mailObj"]);
        if (!string.IsNullOrEmpty(context.Request.QueryString["mailObj"]) && context.Request.QueryString["mailObj"] != "null")
        {
            data = js.Deserialize<returnMail>(context.Request.QueryString["mailObj"]);
       string senderName=context.Server.UrlDecode(data.senderName)
        }
  }

 



posted @ 2020-03-18 18:23  chenze  阅读(533)  评论(0编辑  收藏  举报
有事您Q我