PRB: Setting the HTTP Header in the <browserCaps> Section Does Not Work in ASP.NET 1.1 (828978)



The information in this article applies to:

  • Microsoft ASP.NET (included with the .NET Framework 1.1)

SYMPTOMS

In Microsoft ASP.NET 1.1, when you set the HTTP header value in the <browserCaps> section of a Web.config file, the set value does not work as expected.

WORKAROUND

To work around this problem, set the value of the isMobileDevice property to true in the <browserCaps> section of the Web.config file as follows:
<configuration>
<system.web>

<browserCaps>
 isMobileDevice="true" 
       <use var="HTTP_ACCEPT_LANGUAGE" as="accept_language" />
           <filter>
                <case match="en-us" with="%{accept_language}">
                    browser = "Testing browser type"
                </case>
            </filter>
</browserCaps>
</system.web>

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce the Behavior

Create an ASP.NET Web Application

  1. Start Microsoft Visual Studio .NET.
  2. Use Microsoft Visual C# .NET or Microsoft Visual Basic .NET to create an ASP.NET Web Application project that is named TestWeb1. By default, WebForm1.aspx is created.
  3. Right-click the WebForm1.aspx Web form, and then click View HTML Source.
  4. Replace the existing code with the following code:

    Visual C# .NET Code
    <%@ Page language="c#" %>
    <html>
      <head>
        <title>WebForm2</title>    
        <SCRIPT runat=server>
        public void Page_Load(Object sender, EventArgs e) 
        {
        Response.Write(Request.Browser.Browser);
        }
        </SCRIPT>
      </head>
      <body MS_POSITIONING="GridLayout">	
        <form id="Form1" method="post" runat="server">
         </form>	
      </body>
    </html>
    
    Visual Basic .NET Code
    <%@ Page language="vb" %>
    <html>
      <head>
        <title>WebForm2</title>    
        <SCRIPT runat=server>
       Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) 
        Response.Write(Request.Browser.Browser)
       End Sub      
        </SCRIPT>
      </head>
      <body MS_POSITIONING="GridLayout">	
        <form id="Form1" method="post" runat="server">
         </form>	
      </body>
    </html>
    

Modify the Web.config File

  1. In Notepad, open the Web.config file for the ASP.NET Web Application project that you have created.
  2. To override the HTTP header for the browser variable, add the <browserCaps> section to the <system.web> section as follows:
    <configuration>
    <system.web>
    
    <browserCaps>
           <use var="HTTP_ACCEPT_LANGUAGE" as="accept_language" />
               <filter>
                    <case match="en-us" with="%{accept_language}">
                        browser = "Testing browser type"
                    </case>
                </filter>
    </browserCaps>
    </system.web>
    
    </configuration>
    
  3. Save the Web.config file.

Run the Application

  1. On the Debug menu, click Start to run the application.
  2. You notice that the value IE is displayed in Microsoft Internet Explorer, and that the value Netscape is displayed in the Netscape browser. However, the expected value is Testing browser type.

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web sites: For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

307626 INFO: ASP.NET Configuration Overview


Modification Type:MajorLast Reviewed:10/16/2003
Keywords:kbweb kbBrowse kbConfig kbprb KB828978 kbAudDeveloper