Solved

how to support google chrome also in my code

Posted on 2013-06-04
7
578 Views
Last Modified: 2013-07-02
I have the below function and now I also have to add google chrome to it kindly suggest?

Private Function CheckBrowserVersion() As Boolean
            'lblLoginMSG.Text = Request.Browser.Browser.ToUpper() & " :Platform= " & Request.Browser.Platform & ":" & Request.Browser.Version
            'Return True
            '******************************************************************
            '* Support the following browsers on Windows 2000/XP platform    *
            '* IE 5.5, 6.0                                                    *      
            '* NetScape 6.0, 7.1, 7.2                                         *
            '* Mozilla Firefox 1.0                                            *
            '******************************************************************

            Try
                If Request.Browser.Platform.ToUpper = "MACPPC" Then
                    'Check for apple macintosh platform
                    If Request.Browser.Browser.ToUpper().IndexOf("IE") >= 0 Then
                        If Decimal.Parse(Request.Browser.Version) >= 5.23 Then
                            Return True
                        End If
                    ElseIf Request.Browser.Browser.ToUpper().IndexOf("NETSCAPE") >= 0 Then
                        If Decimal.Parse(Request.Browser.Version) >= 5.0 Then
                            Return True
                        End If
                    Else

                        Select Case Request.Browser.Browser.ToUpper()
                            Case "GECKO"
                                If Request.Browser.Version > 1.6 Then
                                    Return True
                                End If
                            Case Else
                                Return False
                        End Select
                    End If
                    Return False
                Else
                    'Check for windows and other
                    If Request.Browser.Browser.ToUpper().IndexOf("IE") >= 0 Then
                        If Decimal.Parse(Request.Browser.Version) >= 5.5 Then
                            Return True
                        End If
                    ElseIf Request.Browser.Browser.ToUpper().IndexOf("NETSCAPE") >= 0 Then
                        If Decimal.Parse(Request.Browser.Version) >= 5.0 Then
                            Return True
                        End If
                    ElseIf Request.Browser.Browser.ToUpper().IndexOf("FIREFOX") >= 0 Then
                        If Request.Browser.MajorVersion >= 2 Then
                            Return True
                        End If
                    Else
                        Select Case Request.Browser.Browser.ToUpper()
                            Case "GECKO"
                                If Decimal.Parse(Request.Browser.Version) > 1.6 Then
                                    Return True
                                End If
                            Case Else
                                Return False
                        End Select
                        Return False
                    End If
                End If

            Catch
                Try
                    WriteLog(Date.Now & vbCrLf & Err.Description)
                    Return False
                Catch ex1 As Exception
                    Return False
                End Try
            End Try
        End Function
0
Comment
Question by:welcome 123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
7 Comments
 
LVL 80

Accepted Solution

by:
David Johnson, CD, MVP earned 250 total points
ID: 39221060
Google Chrome UserAgent On a linux machine

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.34 Safari/534.24

Chrome UserAgent on a 64 bit windows machine
Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36

Firefox UserAgent
Mozilla/5.0 (Windows NT 6.2; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0

IE 10 User Agent
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)
0
 

Author Comment

by:welcome 123
ID: 39235975
Frankly speaking I could not understand anything can you tell me what I need to add in my procedure above to allow google chrome?
0
 
LVL 80

Expert Comment

by:David Johnson, CD, MVP
ID: 39236026
Since you are using the user-agent to do various items I gave you some user-agents to work with.
0
 

Author Comment

by:welcome 123
ID: 39239007
The above code in a dot net code in my application and we use windows environment so in my CheckBrowserVersion method what do I need to add to allow goohgle chrome is it :

ElseIf Request.Browser.Browser.ToUpper().IndexOf("Chrome") >= 0 Then
                        If Request.Browser.MajorVersion >= 2 Then
                            Return True
                        End If
0
 
LVL 23

Assisted Solution

by:Roopesh Reddy
Roopesh Reddy earned 250 total points
ID: 39290340
Hi,

You can try this -

Response.Write(Request.Browser.Type)
Response.Write(Request.Browser.Version)

Open in new window


Request.Browser.Type will give you the Browser name and version! I checked in .NET 4.0 and it worked for IE, Firefox and Chrome!

Hope it helps u...
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Get sourcecode path 14 46
Google Chrome not remembering website passwords 7 34
Google Chrome GPO Not Applying 5 26
Web page design problem 3 14
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question