简体   繁体   English

IE11显示html页面的问题

[英]IE11 issue with displaying html page

I am upgrading Internet Explorer version from IE8 to IE 11. But while testing our code on IE11 there is one issue we are facing. 我正在将Internet Explorer版本从IE8升级到IE 11.但是在IE11上测试我们的代码时,我们遇到了一个问题。

One of HTTP request basically returns the HTML page from server to client. HTTP请求之一基本上将HTML页面从服务器返回到客户端。 This request is working fine in IE8 and displaying web page correctly but when we launch that request from IE11 its displaying HTML source code instaed of web page in browser. 此请求在IE8中正常工作并正确显示网页,但是当我们从IE11启动该请求时,它在浏览器中显示网页的HTML源代码。

I tried to save those source code(which displayed in browser) manually with .html extension and launched locally. 我试图用.html扩展名手动保存那些源代码(在浏览器中显示)并在本地启动。 Its displaying correctly when launched locally. 在本地启动时正确显示。 This means HTML page which is returning from server is correct and there is issue with rendering? 这意味着从服务器返回的HTML页面是正确的,并且存在渲染问题?

Here is the HTTP header request and response which are different in IE8 and IE11, Grabbed through Fiddler--> 这是HTTP头请求和响应,它们在IE8和IE11中有所不同,通过Fiddler - >获取

IE 8: IE 8:

Request Header: 请求标题:

Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, / 接受:application / x-ms-application,image / jpeg,application / xaml + xml,image / gif,image / pjpeg,application / x-ms-xbap,application / vnd.ms-excel,application / vnd.ms- powerpoint,application / msword, /

User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E) User-Agent:Mozilla / 4.0(兼容; MSIE 7.0; Windows NT 6.1; WOW64; Trident / 4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0 ; InfoPath.3; .NET4.0C; .NET4.0E)

Response Header: 响应标题:

Content-Type: text/plain; 内容类型:text / plain; charset=ISO-8859-1 字符集= ISO-8859-1

IE 11: IE 11:

Request Header: 请求标题:

Accept: text/html, application/xhtml+xml, / 接受:text / html,application / xhtml + xml, /

User-Agent: Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko User-Agent:像Gecko一样的Mozilla / 5.0(Windows NT 6.1; Trident / 7.0; rv:11.0)

Response Header: Content-Type: text/plain; 响应标头:内容类型:text / plain; charset=ISO-8859-1 字符集= ISO-8859-1

I am new to all this and not getting what steps to take next. 我是这一切的新手,没有采取下一步采取的措施。 Is this happening due to browser is not able to receive page in correct format? 这是否因为浏览器无法以正确的格式接收页面而发生? Changing server side code is little bit difficult as server creates pages dynamically. 由于服务器动态创建页面,更改服务器端代码有点困难。 Is there any simple solution for this? 这有什么简单的解决方案吗?

Thanks in advance. 提前致谢。

Your Response header's Content-Type is showing "text/plain" which explains why the source is displaying instead of the source getting rendered. 您的Response标头的Content-Type显示“text / plain”,它解释了显示源的原因,而不是显示源的内容。

I believe there's no other way but change your server-side code and set the Content-Type to "text/html" of the response when sending the dynamically generated page 我相信没有别的方法可以改变你的服务器端代码,并在发送动态生成的页面时将Content-Type设置为响应的“text / html”

With Content-Type: text/plain you're essentially telling the browser yourself "please treat and show this as plain text" - it's just following orders. 使用Content-Type: text/plain你实际上是在告诉浏览器“请将其视为纯文本” - 它只是遵循命令。

The obvious fix is to force the content type to text/html , this should be a minor change in the serverside code. 显而易见的解决方法是将内容类型强制为text/html ,这应该是服务器端代码中的一个小改动。 If the webserver is Apache, you could enforce this by using mod_headers and a .htaccess file or some vhost configuration. 如果Web服务器是Apache,您可以使用mod_headers和.htaccess文件或某些vhost配置来强制执行此操作。 If the webserver is not Apache, you could use another small Apache server with mod_proxy to add these headers. 如果Web服务器不是Apache,您可以使用另一个带有mod_proxy的小型Apache服务器来添加这些标头。

I'm highly surprised this went 'right' in IE8, probably you're also triggering quirks (compatibility) mode there. 我非常惊讶IE8中的'正确',可能你也在那里触发了怪癖(兼容性)模式。 If fixing the content-type directly is not feasible you could try forcing IE11 to run in IE8 mode by adding the following line to the <head> section of the output: 如果直接修复内容类型是不可行的,您可以尝试通过将以下行添加到输出的<head>部分来强制IE11在IE8模式下运行:

<meta http-equiv="X-UA-Compatible" content="IE=8" />

This is however an ugly workaround, and it will stay broken in Firefox, Chrome, Safari and other standards-conforming browsers, just like IE11 they will just follow your orders and show the content as plain text. 然而,这是一个丑陋的解决方法,它将在Firefox,Chrome,Safari和其他符合标准的浏览器中保持不变,就像IE11一样,它们只会遵循您的订单并将内容显示为纯文本。 In the end they're just doing as you tell them. 最后他们就像你告诉他们一样。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM