Solved

how to support google chrome also in my code

Posted on 2013-06-04
7
570 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

744 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

11 Experts available now in Live!

Get 1:1 Help Now