Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set encoding to utf-8 on a IIS web.config file?

I have this

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

    <appSettings>
        <add key="ContentServer" value="true" />
    </appSettings>
    <connectionStrings />

    <system.web>
        <trace enabled="false" requestLimit="25" pageOutput="false" traceMode="SortByTime" localOnly="false" />
        <customErrors mode="Off" />
        <compilation debug="false" />
        <authentication mode="Windows" />
    </system.web>
</configuration>

How do I set the encoding to utf-8 for files sent to client. Actually There can be other types of files sent to clients like js,css,images. But I have aspx pages, that I want to set text/html; charset=utf-8" content-type to. How can I add this to this web.config code?

Thanks

like image 223
omega Avatar asked Oct 30 '25 04:10

omega


1 Answers

You need to set the responseEncoding attribute of the globalization element.

<globalization
    responseEncoding="utf-8"
/>

In context:

<configuration>
    <system.web>
        <globalization 
           requestEncoding="utf-8"
           responseEncoding="utf-8"
        />
    </system.web>
</configuration>
like image 69
John Wu Avatar answered Nov 01 '25 23:11

John Wu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!