Solved

how to support google chrome also in my code

Posted on 2013-06-04
7
571 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
  • 2
  • 2
7 Comments
 
LVL 78

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 78

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Code works but I need to redo it and assign values to Model 7 32
Angular JS Route 3 47
What .NET URL re-routing tool did I use? 2 36
Code works but it's slow 23 30
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now