添加和QUOT;字符集"所有的ASP.NET MVC的HTTP响应 [英] Adding "charset" to all ASP.NET MVC HTTP responses

查看:168
本文介绍了添加和QUOT;字符集"所有的ASP.NET MVC的HTTP响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种简单的方法来指定所有正常的观点是一个ASP.NET MVC应用程序都已经追加的charset = UTF-8 内容类型查看()缺乏一个覆盖,使您可以指定内容类型的ActionResult 和朋友似乎并不暴露任何事情,无论是。的动机显然是要解决Internet Explorer的猜测正确的编码类型,我反过来想做些什么来避免UTF-7跨站脚本攻击。

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.

推荐答案

这也许在你的web.config会做的魔力呢?

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

<configuration>
  <system.web>
    <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
  </system.web>
</configuration>

这篇关于添加和QUOT;字符集&QUOT;所有的ASP.NET MVC的HTTP响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆