locked
my asp.net Menu control doesn't show correctly in Safari and Chrome at first time visit RRS feed

  • Question

  • User-635215137 posted

    Hi:

    I have this problem before, after I search online, I implemented below code in my master page load()

    protected void Page_Load(object sender, EventArgs e)
        {

            if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
            {
                Request.Browser.Adapters.Clear();
            }

        }

    However, this code works only when I refresh my webpage, at the very beginning, it always not showing the .net menu control correctly?

    Please let me know if you have any suggestion?

    Thanks a  lot.

    JT

    Friday, April 2, 2010 2:54 PM

Answers

  • User1080785583 posted

    Add a new aspnet folder called App_Browsers to your project.

    Then add this to your web.config.

    <system.web>
    		<browserCaps>
    			<case match="Chrome/(?'version'(?'major'\d+)(?'minor'\.\d+)\.\d+.\d+)\sSafari/\d+\.\d+browser=Chrome version=${version} majorversion=${major} minorversion=${minor}"></case>
    		</browserCaps>


     

    Then add this file to your App_Browsers folder in your project.

    <!--
        You can find existing browser definitions at
        <windir>\Microsoft.NET\Framework\<ver>\CONFIG\Browsers
    -->
    <browsers>
        <browser id="NewBrowser" parentID="Mozilla">
            <identification>
                <userAgent match="Unique User Agent Regular Expression" />
            </identification>
    
            <capture>
                <userAgent match="NewBrowser (?'version'\d+\.\d+)" />
            </capture>
    
            <capabilities>
                <capability name="browser" value="My New Browser" />
                <capability name="version" value="${version}" />
            </capabilities>
        </browser>
    
        <browser refID="Mozilla">
            <capabilities>
                <capability name="xml" value="true" />
            </capabilities>
        </browser>
    	<browser refID="safari1plus">
    		<controlAdapters>
    			<adapter controlType="System.Web.UI.WebControls.Menu" adapterType="" />
    		</controlAdapters>
    	</browser>
    
    </browsers>
    


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 7, 2010 2:56 PM

All replies

  • User1080785583 posted

    Add a new aspnet folder called App_Browsers to your project.

    Then add this to your web.config.

    <system.web>
    		<browserCaps>
    			<case match="Chrome/(?'version'(?'major'\d+)(?'minor'\.\d+)\.\d+.\d+)\sSafari/\d+\.\d+browser=Chrome version=${version} majorversion=${major} minorversion=${minor}"></case>
    		</browserCaps>


     

    Then add this file to your App_Browsers folder in your project.

    <!--
        You can find existing browser definitions at
        <windir>\Microsoft.NET\Framework\<ver>\CONFIG\Browsers
    -->
    <browsers>
        <browser id="NewBrowser" parentID="Mozilla">
            <identification>
                <userAgent match="Unique User Agent Regular Expression" />
            </identification>
    
            <capture>
                <userAgent match="NewBrowser (?'version'\d+\.\d+)" />
            </capture>
    
            <capabilities>
                <capability name="browser" value="My New Browser" />
                <capability name="version" value="${version}" />
            </capabilities>
        </browser>
    
        <browser refID="Mozilla">
            <capabilities>
                <capability name="xml" value="true" />
            </capabilities>
        </browser>
    	<browser refID="safari1plus">
    		<controlAdapters>
    			<adapter controlType="System.Web.UI.WebControls.Menu" adapterType="" />
    		</controlAdapters>
    	</browser>
    
    </browsers>
    


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 7, 2010 2:56 PM
  • User1080785583 posted

    I forgot to include, before the

    Then add this file to your App_Browsers folder in your project. 
     add a new item in your App_Browsers folder that is a .Browser file. 

    Wednesday, April 7, 2010 2:58 PM
  • User882035056 posted

    pardon me - i am new to ASP.net.

    i'm trying to get this to work, but so far, no luck. My project is made up of multiple solutions so does the App_browsers folder need to be in every solution? and does the code need to be in every web.config file?

    Monday, April 19, 2010 11:57 AM
  • User-665581087 posted

    Thank you very much 

    Thursday, April 29, 2010 5:17 AM
  • User-635215137 posted

    Thank you: Xequence.

    It works great! Here is the code details:

    Asp.net menu control doesn't show correctly on Safari and Chrome - Solved


    Friday, May 28, 2010 2:54 PM