One aspx page to have utf-8 encoding

后端 未结 2 1698
旧时难觅i
旧时难觅i 2021-01-03 03:54

What should I do to change one aspx page to have utf-8 encoding?

my web.config has the following code:


  

        
相关标签:
2条回答
  • 2021-01-03 04:25

    Try this;

    <configuration>
     <system.web>
      <globalization
        fileEncoding="utf-8" 
        requestEncoding="utf-8" 
        responseEncoding="utf-8"
        culture="en-US"
        uiCulture="de-DE"
       />
     </system.web>
    </configuration>
    

    To set the encoding for an individual page, set the RequestEncoding and ResponseEncoding attributes of the @ Page directive:

    <%@ Page RequestEncoding="utf-8" ResponseEncoding="utf-8" %>
    

    Or you can use location like this:

    <location path="home.aspx">
        <system.web>
            <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
        </system.web>
    </location>
    

    Read more: How to: Select an Encoding for ASP.NET Web Page Globalization.

    0 讨论(0)
  • 2021-01-03 04:29

    Try to insert

    Response.ContentEncoding = System.Text.Encoding.UTF8;
    

    In your Page_Load if you want to do it dynamically.

    0 讨论(0)
提交回复
热议问题