使用__doPostBack的IE 11浏览器问题

时间:2013-09-17 16:17:40

标签: asp.net asp.net-4.0 windows-2003-webserver

我在{7}}中描述的Windows 7上的新IE 11遇到了同样的问题:

基本上,问题是ASP.NET 4.0中的浏览器定义文件中存在一个错误,因此IE 11无法正确呈现__doPostBack函数。我尝试应用上面文章中描述的修复无效;最有可能的原因是它是为IE 10编写的。为了说明问题,我发布了浏览器呈现的相同文件的源代码视图:一个来自IE 10,另一个来自IE 11。

IE 10:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title></head>
<body>
    <form name="form1" method="post" action="BrowserTest.aspx" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTQ1OTQ0MTYyOWRkhppg54D0Mn30nLC/IZTLGlfBr38aeprB3xTAohhbzJQ=" />
</div>
<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}    
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
    theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>
<script src="/WebResource.axd?d=VkfLtYKVwqSRUzJ5c5unJXsrYfD7JD99cKOnK4EzAlBtmGvv5qOEADPvBEF-Abv4R8XOPCOVzoUKZpOWLoWkLmS5Ko2jc6gP0c0boPwDWlQ1&amp;t=634937341768794884" type="text/javascript"></script>

<div>

    <input type="hidden" name="__PREVIOUSPAGE" id="__PREVIOUSPAGE" value="IrJnCf-ARaAvUp2VObKy5G0fSgiunbCJICjf2oeC8yUbPIidn9rC1G7YJWZJWHRXrSiqArylZSjyapyYzouPdDTljHbP4mz-1oB_2NDwvYM1" />
    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgKjhfvoAQKfwImNC7GPbKaBg2kB2yl1LVVULUkU56rARLobB/VGAPlx9gAH" />
</div>
    <div>
        <a href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl02&quot;, &quot;&quot;, false, &quot;&quot;, &quot;/&quot;, false, true))">LinkButton</a>
    </div>
    </form>
</body>
</html>

IE 11:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>
</title></head>
<body>
    <form name="form1" method="post" action="/BrowserTest.aspx" id="form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTQ1OTQ0MTYyOWRkhppg54D0Mn30nLC/IZTLGlfBr38aeprB3xTAohhbzJQ=" />
<input type="hidden" name="__PREVIOUSPAGE" id="__PREVIOUSPAGE" value="IrJnCf-ARaAvUp2VObKy5G0fSgiunbCJICjf2oeC8yUbPIidn9rC1G7YJWZJWHRXrSiqArylZSjyapyYzouPdDTljHbP4mz-1oB_2NDwvYM1" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgKjhfvoAQKfwImNC7GPbKaBg2kB2yl1LVVULUkU56rARLobB/VGAPlx9gAH" />
    <div>
        <a href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl02&quot;, &quot;&quot;, false, &quot;&quot;, &quot;/&quot;, false, true))">LinkButton</a>
    </div>
    </form>
</body>
</html>

是否有其他人遇到此问题,或者是否有人碰巧知道Microsoft是否已发布修复程序?在本文顶部链接中描述的修复程序中,基本上创建了一个文件夹(App_Browsers),其中包含FireFox和IE的定义文件。这是我尝试过的解决方案,我希望它能够适应未来需求,以应对这种情况。

我还应该补充说,我们遇到此问题的服务器是Windows 2003机器。我们还有一个2008年的盒子作为我们的开发服务器,这不是问题。我们计划在不久的将来更新生产箱,但可能在此之前不会成为我们的一些用户的问题。在一篇类似的帖子中,解决方案是升级到ASP.NET 4.5,但这并不是我认为我们现在准备做的事情,除非这是唯一的选择。在另一篇文章中,显然已经发布了一个针对它的修补程序,但它没有被投票或被批准为原始海报的公认答案,所以这就是为什么我要继续并发布这个问题,希望有人有一个明确的答案。

3 个答案:

答案 0 :(得分:0)

斯科特汉塞尔曼在这里写了一篇关于此的文章:

http://www.hanselman.com/blog/IE10AndIE11AndWindows81AndDoPostBack.aspx

答案 1 :(得分:0)

我遇到了同样的问题。只需在项目中创建一个名为App_Browsers的新文件夹,然后在该文件夹中创建一个新文件并将其命名为ie.browser。在文件中添加此代码。

<browsers>
  <browser id="IE11" parentID="Mozilla">
    <identification>
      <userAgent match="Trident\/7.0; rv:(?'version'(?'major'\d+)(\.(?'minor'\d+)?)(?'letters'\w*))(?'extra'[^)]*)" />
      <userAgent nonMatch="IEMobile" />
    </identification>
    <capture>
      <userAgent match="Trident/(?'layoutVersion'\d+)" />
    </capture>
    <capabilities>
      <capability name="browser"              value="IE" />
      <capability name="layoutEngine"         value="Trident" />
      <capability name="layoutEngineVersion"  value="${layoutVersion}" />
      <capability name="extra"                value="${extra}" />
      <capability name="isColor"              value="true" />
      <capability name="letters"              value="${letters}" />
      <capability name="majorversion"         value="${major}" />
      <capability name="minorversion"         value="${minor}" />
      <capability name="screenBitDepth"       value="8" />
      <capability name="type"                 value="IE${major}" />
      <capability name="version"              value="${version}" />
    </capabilities>
  </browser>

  <!-- Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11,0) like Gecko -->
  <browser id="IE110" parentID="IE11">
    <identification>
      <capability name="majorversion" match="11" />
    </identification>

    <capabilities>
      <capability name="ecmascriptversion"    value="3.0" />
      <capability name="jscriptversion"       value="5.6" />
      <capability name="javascript"           value="true" />
      <capability name="javascriptversion"    value="1.5" />
      <capability name="msdomversion"         value="${majorversion}.${minorversion}" />
      <capability name="w3cdomversion"        value="1.0" />
      <capability name="ExchangeOmaSupported" value="true" />
      <capability name="activexcontrols"      value="true" />
      <capability name="backgroundsounds"     value="true" />
      <capability name="cookies"              value="true" />
      <capability name="frames"               value="true" />
      <capability name="javaapplets"          value="true" />
      <capability name="supportsCallback"     value="true" />
      <capability name="supportsFileUpload"   value="true" />
      <capability name="supportsMultilineTextBoxDisplay" value="true" />
      <capability name="supportsMaintainScrollPositionOnPostback" value="true" />
      <capability name="supportsVCard"        value="true" />
      <capability name="supportsXmlHttp"      value="true" />
      <capability name="tables"               value="true" />
      <capability name="supportsAccessKeyAttribute"    value="true" />
      <capability name="tagwriter"            value="System.Web.UI.HtmlTextWriter" />
      <capability name="vbscript"             value="true" />
    </capabilities>
  </browser>
</browsers>

答案 2 :(得分:0)

在我的情况下,安装.NET 4.5.1是解决方案