Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set a default content-type of text/html in my web.config?

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

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?

Thanks,

Adrian

Edit: 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.

like image 607
Adrian Grigore Avatar asked May 04 '10 18:05

Adrian Grigore


2 Answers

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.

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.

like image 172
Blegger Avatar answered Sep 27 '22 22:09

Blegger


Content type for aspx views is already set to text/html.

Content-Type: text/html; charset=utf-8
like image 39
Darin Dimitrov Avatar answered Sep 27 '22 22:09

Darin Dimitrov