Problem with default answer Content-Type

I have a website that has the following Doctype:

<!DOCTYPE HTML> <html>...</htm> 

I found a problem that caused some mobile browsers to break (blackberries and old androids). For example, in Android, when the request is executed, it sends this header:

 Accept: application/xml,appliation/xhtml+xml,text/html ... 

The problem is that my site is not XHTML compliant, but IIS decides that since the browser requesting the page prefers xhtml, then it should serve this instead of text/html .

I tried to override it by adding <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=UTF-8"> to the page, but it does not work.

I am trying to figure out the easiest way to tell iis to stop xhtml service for all http://mydomain.com/mobile requests. I thought about this by overwriting Response.Content-Type in an HttpModule.

Is there something I'm missing here? What is the best way to fix this?

+4
source share
2 answers

IIS lacks the mentioned funcionality (to override the type of output content from .NET), as does the application to do this. What happens on mobile phones when they break, can you provide an HTTP debug trace?

To check if ContentType is really a problem, add this to the Page_Load event on one of your pages, then view this page on the affected mobile device.

 Response.ContentType = "text/html"; 

Mobile browsers have quirks for desktop versions; they parse JavaScript and handle DOM elements differently. For example, Mobile Safari has an incomplete Date.parse () method that causes JS to break on this page.

Try to launch the browser in debug mode (if possible) and see what the actual error is. Since I don’t see how IIS will change the willy nilly content type, especially to the XHTML type, which means that the basic HTML must be perfect ,

+1
source

Try setting DOCTYPE to <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> and see if that helps . Also, check out the following link:

W3C Recommended Doctype List of Ads

+1
source

All Articles