homepage Welcome to WebmasterWorld Guest from 54.145.183.126
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Conditional Statement, User Agent, Lower Case and Print to Screen
Browser detection code in PHP, translate to ASP.Net
BenjArriola

5+ Year Member



 
Msg#: 3834899 posted 6:03 pm on Jan 26, 2009 (gmt 0)

I am really unfamiliar with ASP code. And I also do not know if the code for ASP.Net is different from ASP.

But I basically need to do this PHP code I wrote, in it's equivalent ASP and ASP.Net code (if they are different)


<?php
if(strpos(strtolower($_SERVER['HTTP_USER_AGENT']),"webkit")) {
echo "<link href=\"http://www.example.com/csspath/layoutwebkit.css" rel=\"stylesheet\" type=\"text/css\" media=\"screen, projection\" />";
}
?>

I tried researching for this first, looking for strpos, user-agent, but I might not be able to put it all together correctly. And if the variable values are not case-sensitive, maybe the strtolower is not needed.

I know there are other ways to make CSS more cross-browser compatible, but the site I am working on is just so messed up and I do not want to do everything from scratch and decided to do browser user-agent detection.

 

Ocean10000

WebmasterWorld Administrator 10+ Year Member



 
Msg#: 3834899 posted 8:08 pm on Jan 26, 2009 (gmt 0)

In Asp.net you can use the following two properties of the Request.Browser object.
"Request.Browser.Browser" to return the browser name.
"Request.Browser.Version" to return the browser version.

Asp.net has a built in browser identification system which can be used on a per page bases. So you do not need to try and figure out for your self the Browser and version details from the User-Agent.

Here is a MS KB Article [support.microsoft.com] on topic.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved