ITPub博客

首页 > > > c#乱码问题用了各种方法 没解决

c#乱码问题用了各种方法 没解决

作者:markriver 时间:2019-10-12 11:46:28 0 删除 编辑
var httpcontext = context.Response;
            httpcontext.Buffer = true;
            httpcontext.ExpiresAbsolute =    DateTime.Now.AddSeconds(0);
            httpcontext.AddHeader("Pragma", "No-Cache");
            httpcontext.Expires = 0;

..

public void ResponseClient(string result, HttpContext context)
        {
            context.Response.Write("{ \"result\":\"" + result + "\"}");
        }


也设置了

Response.ContentType

Response.Charset

都是utf-8 网上有的说在配置文件里面加globalization  也无效

最后对输出的字符串这样处理

 HttpUtility.UrlEncode(str,System.Text.Encoding.GetEncoding("utf-8"));

还是乱码

在页面设置<meta http-equiv="content-type" content="text/html;charset=utf-8">

都没有用!

浏览器图片:

求解决

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/818/viewspace-3144438/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2020-07-03

  • 博文量
    502
  • 访问量
    18493