Stop sniffing what my browser is

    With an enviable frequency in the blog of the Opera browser developers, messages appear that Opera cannot parse a page and the user sees something like this: You can see the effect on any of these links . At the same time, in other popular browsers, pages are displayed normally, just like in Opera, if you ask to parse a document as HTML, and not as XML (link “Reparse document as HTML”). At some point, I wondered why this was happening. There are not many options, either Opera cannot parse XML, which other browsers can parse, or other browsers do not try to parse pages as XML, but consider that it is HTML. There was no need to search for the cause for a long time, it turned out to be the server’s response:






    Answer Opera

    Firefox Response

    It turns out that the server simply “lies” to some browsers. At the same time, we can say for sure that he makes a decision only on the basis of the User-Agent string. If, for example, in Opera you set Browser identification in the properties of the site as Internet Explorer, or Firefox, the pages begin to open miraculously. The converse is also true, if you set the user agent as “Mozilla / 5.0 (Windows; U; Windows NT 5.1; ru-RU)” in Safari, then it will also be given the content supposedly application / xhtml + xml, and it will also not be able to parse it: It turns out that not only Opera suffers, but any other browser that is not recognized as “your own”.





    All examined sites with this error have one thing in common - they are written in ASP.NET 2.0. I don’t know if this is a mistake of the Microsoft team, or is it the work of homegrown administrators of such sites (even so, not all sites written in ASP.NET 2.0 suffer from such garbage). I just want to give advice to the developers, which I wrote in the title.

    And users can only be advised to change the user agent for such sites. In the same Opera, this can be done on the Network tab in the properties of a broken site.

    Also popular now: