Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding "charset" to all ASP.NET MVC HTTP responses

Is there an easy way to specify all "normal" views is an ASP.NET MVC app are to have charset=utf-8 appended to the Content-Type? View() lacks an override that allows you to specify the Content-Type, and ActionResult and friends don't seem to expose anything, either. The motivation is obviously to work around Internet Explorer guessing the "correct" encoding type, which I in turn want to do to avoid UTF-7 XSS attacks.

like image 717
Benjamin Pollack Avatar asked Nov 16 '09 18:11

Benjamin Pollack


1 Answers

Maybe this in your web.config will do the magic?

<configuration>
  <system.web>
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
  </system.web>
</configuration>
like image 181
Mickel Avatar answered Sep 21 '22 18:09

Mickel