Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


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>

↑ Back to the top


Status

This behavior is by design.

↑ Back to the top


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.

↑ Back to the top


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

↑ Back to the top


Keywords: KB828978, kbbrowse, kbconfig, kbprb, kbweb

↑ Back to the top

Article Info
Article ID : 828978
Revision : 4
Created on : 4/19/2007
Published on : 4/19/2007
Exists online : False
Views : 308