我如何可以设置我的web.config默认的内容类型text / html的? [英] How can I set a default content-type of text/html in my web.config?

查看:364
本文介绍了我如何可以设置我的web.config默认的内容类型text / html的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想设置默认内容类型的网页在我的ASP.NET MVC应用程序为text / html。

I'd like to set the default content-type for web pages in my ASP.NET MVC application to text/html.

我知道这可以通过添加的ContentType =text / html的我所有的&LT来完成;%页%>元素,但我preFER使用web.config文件来代替。我该怎么做?

I know this can be done by adding a ContentType="text/html" to all of my <%Page%> elements, but I'd prefer to use the web.config instead. How can I do that?

谢谢,

阿德里安

编辑:我知道文本/ HTML是ASP.NET默认,但不知什么原因,还是歌剧尝试来分析我的网站作为XHML除非我明确设置内容类型我&LT;%页%>元素。

I know that "text/HTML" is the ASP.NET default, but for unknown reasons Opera still tries to parse my web site as XHML unless I explicitly set the content-type in my <%Page%> element.

推荐答案

我们有完全相同的问题,对我们来说,问题是,我们从$获得C $ CPLEX的mobile.browser文件具有强制asp.net中的错误总是告诉我们XHTML发送它们歌剧的桌面版本。我删除了mobile.browser文件,并解决了问题。看来,我们可以发现,将覆盖从mobile.browser指令的唯一的事情就是指定的ContentType =每个意见&LTtext / html的;%@页%>标记。即使设置内容类型在Global.asax中做零差价。

We had the exact same problem and the issue for us was that the mobile.browser file we got from CodePlex has a bug that forces asp.net to always tell the desktop version of opera that we are sending them xhtml. I removed the mobile.browser file and it resolved the issue. It seems the only thing we could find that would override the directive from the mobile.browser was to specify the ContentType="text/html" on each views <%@ Page %> tag. Even setting the content type in global.asax made zero difference.

更新:我已经发现,以preferredRenderingMime一个名为从mobile.browser文件中删除所有功能节点将解决这个问题,还是让我们来识别移动浏览器

UPDATE: I have found that removing all of capability nodes with a name of "preferredRenderingMime" from the mobile.browser file will fix this issues and still allows us to identify mobile browsers.

这篇关于我如何可以设置我的web.config默认的内容类型text / html的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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