IE10, IE11 user-agent website cannot write cookie problem [go]

Source: Internet
Author: User

Have you ever experienced the use of a Web site or management system that involves cookie manipulation, IE 6, 7, 8, 9 run well, only to the IE10, 11 these high-version browser is not? Well, the problem is that the farmer has met 2 times in 2 consecutive days. So, let's take a look at the causes and consequences of this problem.

First of all, this 2 times the use of the scene, one is in a page, the first to save the cookie, and then storage records related data, but published to the production environment, the warehousing operation did not occur; Later, the problem card is found by printing the log here:

if (Request.Browser.Cookies)

That is, in the context of the client is IE10, this returns false! Nani, IE10 does not support cookies under default configuration? Microsoft, you play with me.

The second time is the upgrade test of a certain city, in the IE10 environment, since the service website Login failed; This is a strange question, because it has been upgraded to several cities, IE10 use is normal. This greatly aroused the interest of the Yards farmers, which led to this article.

After describing the scene, we analyze and analyze it. Although the intuition tells the code farmer, may be the cookie reads or writes the question, but after all the intuition this thing is not reliable, we still have to use the fact and the evidence to speak. International practice, first grab an HTTP packet to see:

is the HTTP response header returned by the server when the login failure is IE10, the HTTP response header returned by the server when the other browser is logged in normally, notice the red box callout part;

The direct cause of the problem is clear: when the server responds to the request, there is no postback Set-cookie header, and the client browser cannot write the Cookie without the header. Therefore, the self-service Web site based on form authentication (which is credited to the cookie) will not be able to log in.

At this point, you may find it strange, why only IE10, IE11 will be so, other IE browser running the completed? Well, to satisfy your curiosity, we continue to analyze.

If your machine is loaded. NET of the Framework, open this directory C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\Browsers. Under Popular Science, the. browser files in the folder are globally accessed to identify the browser that made the request and identify the features that these browsers have. If you want to make custom modifications (such as for a specific mobile device), simply copy the corresponding. browser file to the application's \app_browsers folder to modify it. First open the IE.browser file with Notepad,

Note the regular expression labeled red in the figure, and then take a look at Microsoft's published IE10 user-agent: mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; trident/6.0), the MSIE version number is now 2 digits (10) from the previous 1-digit number (5-9), and it is obvious that the above is not matched. So, because IE10 's user-agent could not be correctly identified, ASP. NET sees it as an unknown browser that does not support cookies, resulting in a series of cookie-related problems.

The root of the problem is finally known, so how to solve it?

In fact, this issue has been officially confirmed by Microsoft, is a IE10 bug, in fact, can also be considered as ASP. NET 2.0, 3.5, 4.0 bug, because these versions are not recognized IE10 user-agent. Microsoft has specifically released hotfix to fix this problem:

    • Kb2600088:hotfix for ASP. NET in the Microsoft.NET Framework 4.0
    • Kb2608565:hotfix applies to ASP. NET Framework 3.5.1
    • Kb2600100:hotfix applies to ASP. NET Framework 3.5 SP1 in the. NET Framework 2.0 SP2

Many of the code farm Windows Server will automatically update the installation patches, so the other city in Scenario 2 is normal, in fact, because these servers have been patched, some new shelves, reinstall the system of the server or automatically update the server is not set the problem is likely to occur such problems ...
If the server does not have operational rights or do not want to patch so troublesome, such as the code farm me, you can also add a browser definition file at the root of the site, the steps are as follows:

1, add a "app_browsers" folder;

2, add a "*.browser" suffix of the file, such as Ie10.browser;

3, add the following content in the file (the following configuration means that all devices and browsers support cookies):

<browsers>       <browser refid= "Default" >            <capabilities><!--to avoid wrong detections of e.g. IE10 to               <capability name= "cookies" value= "true"/>               <capability name= "Ecmascriptversion" value= "3.0"/>            </capabilities>        </browser>   </browsers>  

This is for a site configuration, if you do not want to patch and want to do a global configuration of all sites on the server, how to deal with it? Very easy, in fact, the above has been expressed, the problem is in the IE.browser this file configuration, so we just on the original basis, plus this string "\d{2,}$", so that ASP. NET can identify IE10 user-agent. The modified configuration is as follows:

<capability name= "MajorVersion" match= "^[6-9]|\d{2,}$"/>

After you have finished modifying, compile the modified. browser file into an assembly and install it into the GAC under the command line, and if it is Windows Server 2008, Win7, run the command line as an administrator: C:\Windows\Microsoft.NET\ Framework\v4.0.30319\aspnet_regbrowsers.exe-i

If it is IE11, due to its user-agent "mozilla/5.0 (Windows NT 6.3; trident/7.0; rv:11.0) Like Gecko"The change is bigger, so you need to add the following string to do the matching:

<!--mozilla/5.0 (Windows NT 6.3; trident/7.0; rv:11.0) like Gecko--><browser id= "Ie11preview" parentid= "Mozilla" > <identification> <userage NT Match= "trident/(? ') Layoutversion ' \d+). *RV: (? ') Revision ' (? ') Major ' \d+) (\. (? ') Minor ' \d+)) " /> <useragent nonmatch= "MSIE"/> </identification> <capabilities> <capability        Name= "Browser" value= "IE"/> <capability name= "layoutengine" value= "Trident"/>              <capability name= "layoutengineversion" value= "${layoutversion}"/> <capability name= "IsColor" Value= "true"/> <capability name= "screenbitdepth" value= "8"/> <capability name= "Ecmas Criptversion "value=" 3.0 "/> <capability name=" jscriptversion "value=" 6.0 "/> <capabili        Ty name= "javascript" value= "true"/> <capability name= "javascriptversion" value= "1.5"/> < 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= "Fram Es "value=" true "/> <capability name=" javaapplets "value=" true "/> <capab        Ility name= "Supportscallback" value= "true"/> <capability name= "Supportsfileupload" value= "true"/> <capability name= "Supportsmultilinetextboxdisplay" value= "true"/> <capability name= "SupportsMainta        Inscrollpositiononpostback "value=" true "/> <capability name=" Supportsvcard "value=" true "/> <capability name= "Supportsxmlhttp" value= "true"/> <capability name= "Tables" value= "t Rue "/> <caPability name= "SupportsAccesskeyAttribute" value= "true"/> <capability name= "TagWriter" value= " System.Web.UI.HtmlTextWriter "/> <capability name=" VBScript "value=" true "/> <capabi  Lity name= "Revmajor" value= "${major}"/> <capability name= "Revminor" value= "${minor}" /> </capabilities></browser>

Kick's done!

Happiness is so sudden ~ ~ ~

This article is reproduced

Original address: http://www.cnblogs.com/maoniu602/p/3799958.html

IE10, IE11 user-agent website cannot write cookie problem [go]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.