遇到一个从html页面向asp.net页面post数据时汉字乱码的问题,有没有朋友可以指点一下html页面的meta:
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
html页面中form信息
<form method="POST" action="http://localhost/Login.aspx" name=form1>
<input type="hidden" id="stuName" value="汉字" name="stuName">
<input type=submit value="登录">
</form>以上html页面的信息不能更改,是别的系统提供的我的asp.net页面是utf-8编码的,接收到的stuName是乱码,不想修改webconfig,如何通过编程使接收的stuName正常?

解决方案 »

  1.   

    <globalization requestEncoding="utf-8" responseEncoding="GB2312"/>
    或escape等编码传递
      

  2.   

    传递是可以encode编码,接收后decode解码
      

  3.   

    后台CS页面用this.RegisterHiddenField ("stuName",HttpUtility.UrlEncode(value, Encoding.UTF8));
    前台var stuName=decodeURI(document.all.stuName.value);
    这样试试可以不可以。
    前台就不用隐藏域的INPUT了,因为在后台注册就可以了。
      

  4.   

    后台CS页面用this.ClientScriptManager.RegisterHiddenField ("stuName",HttpUtility.UrlEncode(value, Encoding.UTF8));
    前台var stuName=decodeURI(document.all.stuName.value);
    这样试试可以不可以。
    前台就不用隐藏域的INPUT了,因为在后台注册就可以了。
    上面的那个方法写错了
      

  5.   

    现在最大的问题是前台的html页面我没有权限修改,也不能修改,是别人提供的我需要开发web程序,接收对方系统post的数据,只能在我开发的程序中想办法。
    通过修改我的web程序的web.config文件可以实现,但是我不想修改web.config的globalization项,因为那会影响整个程序,只想在页面中实现这种功能就可以了
      

  6.   

    将你的action="http://localhost/Login.aspx中的
    Login.aspx文件放到一个文件夹下,
    在这个文件夹下再创建Web.config文件,
    在该Web.config中设置:
    <globalization requestEncoding= "gb2312" responseEncoding= "gb2312"  />
    就可以了!!