javascript - Asp.Net Web 表单有时会在 Internet Explorer 中奇怪地混合 HTML 和 JavaScript 响应

标签 javascript html asp.net internet-explorer webforms

我刚开始从头开始开发新的 ASP.NET Web 表单应用程序。

问题:在本地和测试服务器上一切正常。在客户服务器上部署应用程序会出现一些奇怪的行为。

仅在使用 Internet Explorer 时且仅在某些情况下,浏览器中的响应无法正确呈现。我看到 HTML 重复出现,JavaScript 直接呈现在屏幕上,并在错误的位置与 HTML 混合。

一切似乎都是随机发生的。

为 Damon 编辑:我需要 10 声望才能放置图像,这就是有时在 ie 中渲染 html 时出现错误的原因:

    //]]>
</script>

??c?cr??|?04?*?9|u? ?*B?T߮?+mDp??}:?-?؉Ч????H?????:?t??dH$??D" disabled="disabled" class="aspNetDisabled txtSolaLettura" disabled="disabled" style="display:none">
            <option selected="selected" value=""></option>
            <option value="M">M</option>
            <option value="F">F</option>

        </select><input name="ctl00$cpHolderBody$GHOSTIndice§STRINGA§SD" type="text" maxlength="1" id="GHOSTIndice§STRINGA§SD" class="txtSolaLettura" readonly="readonly" /></td><td>Cognome Dichiarante</td><td class="STRINGA"><input type="hidden" name="ctl00$cpHolderBody$CTRLIndice§STRINGA§CD" id="CTRLIndice§STRINGA§CD" value="TextBox§Cognome Dichiarante§strtfrmtndfrmt§strtdcml0nddcml" /><input name="ctl00$cpHolderBody$JSONIndice§STRINGA§CD" type="text" maxlength="30" id="JSONIndice§STRINGA§CD" class="txtSolaLettura" readonly="readonly" /></td>
    </tr><tr>
        <0

TM??OG?[? @K??a?6%\? J???-?????? ???^??y;hK?2cD?>?pK?O?tl00$cpHolderBody$CTRLIndice§STRINGA§ND"id="CTRLIndice§STRINGA§ND"value="TextBox§Nome Dichiarante§strtfrmtndfrmt§strtdcml0nddcml"/>二元分析抄本

为Paul编辑:wcf是rest,发送和接收的数据是json

不知道这是否重要:

  • 在应用程序中,我经常使用 ajax-jQuery 调用 WCF 服务
  • 我(例如在 ajax 调用重定向到其他页面后)有时会手动发布表单 (document.forms[0].submit())。
  • 我还有很多 jQuery 代码,有时在页面内,有时在外部 JS 文件中。
  • 我还使用母版页。

我认为这可能涉及服务器或客户端缓存...或服务器端缓冲...

任何想法将不胜感激。

最佳答案

我将对此进行尝试,并猜测这与 http header 中的字符编码设置不正确以及服务器在渲染时设置了错误的编码有关。

从此page :

You should always specify the encoding used for an HTML or XML page. If you don't, you risk that characters in your content are incorrectly interpreted. This is not just an issue of human readability, increasingly machines need to understand your data too. You should also check that you are not specifying different encodings in different places.

您可以使用fiddler来检查这一点并检查正在发送的 http header 。

我建议按照描述指定编码 here在 MSDN 中。

从该页面:

<configuration>
  <system.web>
    <globalization
      fileEncoding="utf-8"
      requestEncoding="utf-8"
      responseEncoding="utf-8"
      culture="en-US"
      uiCulture="de-DE"
    />
  </system.web>
</configuration>

关于javascript - Asp.Net Web 表单有时会在 Internet Explorer 中奇怪地混合 HTML 和 JavaScript 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22063362/

相关文章:

c# - 必填字段验证器在下拉列表回发时消失

javascript - 当react native出现这个错误时: transformClassesWithDexBuilderForDebug?

javascript - 如何将 'tooltip' 添加到 angular-google-charts 中的时间线图表?

javascript - 如何将所有选定的文本包装到span元素中?

javascript - 通过 activexobject 的 excel 应用程序方法和属性

javascript - console.log 上显示什么类型的数据?

html - 检测列表是否溢出并在 css 中给它一个类

html - 如何阻止浏览器将括号中写的数字转换成圆圈数字①中的(1)等括号内的数字?

asp.net - 是否可以在 IIS 服务器中运行 asp.net 和 java web 应用程序?

c# - 防止VS调试器超时