ModelBinding 中的字符不正确
我有一个问题,我正在开发一个 ASP.NET MVC 项目。网站为土耳其语。当我将此网站发布到 IIS 时,土耳其语字符在网页中变得疯狂,因此我在 web.config 中将全球化设置为“
<globalization fileEncoding="iso-8859-9" requestEncoding="iso-8859-9" responseEncoding="iso-8859-9"/>
此土耳其语字符显示正确后”。
但现在我遇到了另一个问题,当我在输入文本中输入土耳其语文本,然后发布到我的控制器操作时,土耳其语字符再次变得疯狂。
我正确跟踪了 http 消息土耳其语文本 POST 例如:如果我输入“Yücel”(ü 是土耳其语字符)进行输入,我查看 HttpAnalyzer,可以看到发布数据是“Yücel”。当我查看 MVC 自动绑定的操作参数属性时,我看到“Yücel”。
您有什么建议来解决这个问题吗?
i have a problem i am developing an asp.net mvc project. Website is in Turkish Language. When i publish this website to IIS Turkish characters get crazy in web pages so i set globalization in my web.config as
<globalization fileEncoding="iso-8859-9" requestEncoding="iso-8859-9" responseEncoding="iso-8859-9"/>
After this Turkish characters shown correct.
But now i have another problem when i enter Turkish text to an input text and then POST to my controller action, Turkish characters get crazy again.
I tracked the http messages Turkish text POST correctly
ex: If i enter "Yücel" (ü is Turkish character) to input, i looked to HttpAnalyzer i can see that Post Data is "Yücel". When i look to my action's parameter's properties which are binded automatically by MVC, I see "Yücel".
Is there any suggestion from you to fix this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我解决了这个问题,我所做的是,
从
web.config 中删除以下元素
,以便使用默认编码(UTF-8)从我的 Site.Master 中删除以下内容
I fixed the problem, what I did is,
Delete following element from
web.config
so default encoding (UTF-8) will be used<globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
Delete following from my Site.Master
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9"/>
web.config中的requestEncoding值;
必须与网页字符集值相同;
但您也可以通过 web.config 位置标记设置中的页面地址设置来执行其他请求编码过程。
示例:
http:// /www.siimviikman.com/2012/06/12/action-based-request-encoding-in-asp-net-mvc/
In web.config requestEncoding value;
must be same as in web page charset value;
But you can also do other request enconding process by page address setting in web.config location tag setting.
Sample:
http://www.siimviikman.com/2012/06/12/action-based-request-encoding-in-asp-net-mvc/