常用出错总结二(乱码相关)

来源:互联网 发布:sap哪些认证 知乎 编辑:程序博客网 时间:2024/06/05 15:28

为了 引用.js 文件,我在 aspx文件的头部:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SearchShops.aspx.cs" Inherits="SearchShops"  ContentType="text/html" ResponseEncoding="gb2312" %>

这样js文件中的中文不会出现乱码,但我的表单提交时出现又乱码,想是request时系统默认utf-8,
用  uri.unescapeDataString(Request["shopName"])不行,

正确的解决方式:

  <system.web>
    
<!--  全球化
          此节设置应用程序的全球化设置。
    
-->
    
<globalization 
            requestEncoding
="gb2312" 
            responseEncoding
="gb2312" 
   
/>
   
 
</system.web>