<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://isom.uoregon.edu/community/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Duck Bytes : Browser detection</title><link>http://isom.uoregon.edu/community/blogs/castner/archive/tags/Browser+detection/default.aspx</link><description>Tags: Browser detection</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>Browser detection in ASP.NET</title><link>http://isom.uoregon.edu/community/blogs/castner/archive/2007/02/11/Browser-detection-in-ASP.NET-2-2.aspx</link><pubDate>Sun, 11 Feb 2007 22:01:00 GMT</pubDate><guid isPermaLink="false">4ac6e2ff-a44c-42df-b503-9719f53eb121:475</guid><dc:creator>gcastner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://isom.uoregon.edu/community/blogs/castner/rsscomments.aspx?PostID=475</wfw:commentRss><comments>http://isom.uoregon.edu/community/blogs/castner/archive/2007/02/11/Browser-detection-in-ASP.NET-2-2.aspx#comments</comments><description>&lt;p&gt;Here is a code snippet for detecting in which Internet browser a user is viewing your site.&lt;/p&gt;
&lt;p&gt;Note that I usually use two stylesheets. The first, standard.css, contains the styles interpreted the same way by&amp;nbsp;all browsers. I then use a second stylesheet to add or change any styles rendered differently in different browsers.&lt;/p&gt;
&lt;p&gt;In the head tag of the relevant page (a .master page would be a good location) add the following lines (assuming that you use two stylesheets as described above):&lt;/p&gt;
&lt;p&gt;&amp;lt;link href=&amp;quot;/styles/standard.css&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; /&amp;gt;&lt;br /&gt;&amp;lt;link runat=&amp;quot;server&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; id=&amp;quot;stylesheet2&amp;quot; /&amp;gt;&lt;/p&gt;
&lt;p&gt;In the page_load sub of the same page, add the following code:&lt;/p&gt;
&lt;p&gt;&amp;#39;Determine the correct css file depending on the browser&lt;/p&gt;
&lt;p&gt;Dim httprequest1 As HttpBrowserCapabilities = Request.Browser&lt;/p&gt;
&lt;p&gt;Select Case httprequest1.Browser &lt;/p&gt;
&lt;p&gt;Case &amp;quot;IE&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;If httprequest1.Version = &amp;quot;6.0&amp;quot; Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;stylesheet2.href = &amp;quot;ie6.css&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If&lt;/p&gt;
&lt;p&gt;Case &amp;quot;Firefox&amp;quot;, &amp;quot;Mozilla&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;stylesheet2.href = &amp;quot;firefox.css&amp;quot;&lt;/p&gt;
&lt;p&gt;Case Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;stylesheet2.Href = &amp;quot;&amp;quot;&lt;/p&gt;
&lt;p&gt;End Select&lt;/p&gt;
&lt;p&gt;In this example, only two browsers are detected but you could of course add more. You can also add additional versions to each browser.&lt;/p&gt;&lt;img src="http://isom.uoregon.edu/community/aggbug.aspx?PostID=475" width="1" height="1"&gt;</description><category domain="http://isom.uoregon.edu/community/blogs/castner/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://isom.uoregon.edu/community/blogs/castner/archive/tags/Browser+detection/default.aspx">Browser detection</category></item></channel></rss>