开发者

Detecting Chrome using .net 3.5 and C#

开发者 https://www.devze.com 2023-03-07 08:42 出处:网络
Okey,I am using this code to detect the browser <%= Request.Browser.Browser %> When using chrome, it is giving me browser

Okey, I am using this code to detect the browser

<%= Request.Browser.Browser %>

When using chrome, it is giving me browser

AppleMAC-Safari

I need it to say chrome, Ater looking around, i 开发者_如何学Cfound this

Google Chrome/Safari Same Browser Name and Version !

I did all that was given in the answer to the question, but that doesn't help.

I am using VS 2010 and using .net framework 3.5

thankyou.

Edit: I tried doing what is suggested on this page

http://www.codemonkeez.com/2010/06/detect-google-chrome-browser-with.html

it is still giving me

AppleMAC-Safari

:/

thanks again.


Have you tried:

if (Request.UserAgent.Contains("Chrome") && !Request.UserAgent.Contains("Edge"))
{
    //do chrome stuff
}


Use <%= Request.UserAgent %> which will give you something like this:

Mozilla/5.0 (Windows NT 6.1) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.68 Safari/534.24


Note that Chrome didn't exist back in 2005, when Visual Studio 2005 was released.


Try this

<div>
Your browser is: <%=Request.Browser.Browser %>
</div>
0

精彩评论

暂无评论...
验证码 换一张
取 消