Click here to Skip to main content
15,867,568 members
Articles / Web Development / IIS

Browser Detection using ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.63/5 (56 votes)
6 May 2009CPOL5 min read 556.7K   6.3K   186  
Using and updating your machine.config file to better detect browser type in ASP.NET
using System;
using NUnit.Framework;
namespace Ocean.Nunit.HttpCapabilities.CodeProject
{
	/// <summary>
	/// Summary description for Capabilities_Microsoft.
	/// </summary>
	[TestFixture]
	public class Capabilities_Microsoft
	{
		Ocean.Web.HttpCapabilities.Settings Browser;
		Ocean.Web.HttpCapabilities.Result R;
		public Capabilities_Microsoft()
		{
			Browser = new Ocean.Web.HttpCapabilities.Settings(Ocean.Web.HttpCapabilities.EmbededFile.CodeProject);
		}
		[Test]
		public void Test_CLR_1_0()
		{
			#region 1.0.2914
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; .NET CLR 1.0.2914)");
			Assert.AreEqual("1.0.2914",R["clrVersion"], "Browser clrVersion Compare");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; DigExt; .NET CLR 1.0.2914)");
			Assert.AreEqual("1.0.2914",R["clrVersion"], "Browser clrVersion Compare");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.2914)");
			Assert.AreEqual("1.0.2914",R["clrVersion"], "Browser clrVersion Compare");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; {CSC}; .NET CLR 1.0.2914)");
			Assert.AreEqual("1.0.2914",R["clrVersion"], "Browser clrVersion Compare");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Hotbar 3.0; .NET CLR 1.0.2914)");
			Assert.AreEqual("1.0.2914",R["clrVersion"], "Browser clrVersion Compare");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.2914)");
			Assert.AreEqual("1.0.2914",R["clrVersion"], "Browser clrVersion Compare");
			#endregion
			#region 1.0.3705
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.0.2914)");
			Assert.AreEqual("1.0.3705",R["clrVersion"], "Browser clrVersion Compare");
			#endregion
			#region Contains Multple Versions (Test Most Recent Version)
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.0.2914; .NET CLR 1.1.4322)");
			Assert.AreEqual("1.1.4322",R["clrVersion"], "Browser clrVersion Compare");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 1.0.2914)");
			Assert.AreEqual("1.1.4322",R["clrVersion"], "Browser clrVersion Compare");
			#endregion
		}
		[Test]
		public void Test_CLR_1_1()
		{
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 5.01; Windows 98; .NET CLR 1.1.4322)");
			Assert.AreEqual("1.1.4322",R["clrVersion"], "Browser clrVersion Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0; .NET CLR 1.0.3705; .NET CLR 1.1.4322)");
			Assert.AreEqual("1.1.4322",R["clrVersion"], "Browser clrVersion Compare");
						
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 1.0.2914)");
			Assert.AreEqual("1.1.4322",R["clrVersion"], "Browser clrVersion Compare");
		}
		[Test]
		public void Test_CLR_1_2()
		{
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 1.2.30703)");
			Assert.AreEqual("1.2.30703",R["clrVersion"], "Browser clrVersion Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 1.2.30703)");
			Assert.AreEqual("1.2.30703",R["clrVersion"], "Browser clrVersion Compare");

			//-------------------------------------------------------------------
			//1.2.x86dbg did not come in becuase it contains Leters. Current
			//code only imports Numberics
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 1.2.x86dbg; .NET CLR 1.2.x86chk; .NET CLR 1.2.x86ret; .NET CLR 1.2.30509)");
			Assert.AreEqual("1.2.30509",R["clrVersion"], "Browser clrVersion Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.2.x86chk; .NET CLR 1.1.4322)");
			Assert.AreEqual("1.1.4322",R["clrVersion"], "Browser clrVersion Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; MyIE2; .NET CLR 1.1.4322; .NET CLR 1.2.30703)");
			Assert.AreEqual("1.2.30703",R["clrVersion"], "Browser clrVersion Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 1.2.30703)");
			Assert.AreEqual("1.2.30703",R["clrVersion"], "Browser clrVersion Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 1.2.30703)");
			Assert.AreEqual("1.2.30703",R["clrVersion"], "Browser clrVersion Compare"); 
		}

		[Test]
		public void Test_CLR_2_0()
		{
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.40607)");
			Assert.AreEqual("2.0.40607",R["clrVersion"], "Browser clrVersion Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.40426)");
			Assert.AreEqual("2.0.40426",R["clrVersion"], "Browser clrVersion Compare");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 1.0.3705; .NET CLR 2.0.40607)");
			Assert.AreEqual("2.0.40607",R["clrVersion"], "Browser clrVersion Compare");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 2.0.40607)");
			Assert.AreEqual("2.0.40607",R["clrVersion"], "Browser clrVersion Compare");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 2.0.40607; .NET CLR 1.0.3705)");
			Assert.AreEqual("2.0.40607",R["clrVersion"], "Browser clrVersion Compare");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 2.0.40607)");
			Assert.AreEqual("2.0.40607",R["clrVersion"], "Browser clrVersion Compare");
						
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.31113)");
			Assert.AreEqual("2.0.31113",R["clrVersion"], "Browser clrVersion Compare");

						
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; AOL 9.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.40426)");
			Assert.AreEqual("2.0.40426",R["clrVersion"], "Browser clrVersion Compare");

									
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.31113)");
			Assert.AreEqual("2.0.31113",R["clrVersion"], "Browser clrVersion Compare");

									
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; FunWebProducts-MyWay; .NET CLR 1.1.4322; .NET CLR 2.0.40426; .NET CLR 2.0.40607)");
			Assert.AreEqual("2.0.40426",R["clrVersion"], "Browser clrVersion Compare");

									
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; .NET CLR 2.0.41115)");
			Assert.AreEqual("2.0.41115",R["clrVersion"], "Browser clrVersion Compare");

									
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; FunWebProducts-MyWay; .NET CLR 2.0.40607; .NET CLR 1.1.4322; MSIECrawler)");
			Assert.AreEqual("2.0.40607",R["clrVersion"], "Browser clrVersion Compare");
									
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.31113)");
			Assert.AreEqual("2.0.31113",R["clrVersion"], "Browser clrVersion Compare");						

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.41013)");
			Assert.AreEqual("2.0.41013",R["clrVersion"], "Browser clrVersion Compare");
		}
		[Test]
		public void Test_IE_3X()
		{
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/2.0 (compatible; MSIE 3.01; AK; Windows 95)");                  
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("3.01",R.Version, "Browser Version Compare");  
			Assert.AreEqual("System.Web.UI.Html32TextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/2.0 (compatible; MSIE 3.01; Windows 95)");  
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("3.01",R.Version, "Browser Version Compare");   
			Assert.AreEqual("System.Web.UI.Html32TextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/2.0 (compatible; MSIE 3.02; Update a; AK; Windows 95)");        
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("3.02",R.Version, "Browser Version Compare");   
			Assert.AreEqual("System.Web.UI.Html32TextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/2.0 (compatible; MSIE 3.02; Update a; Windows 95)");            
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("3.02",R.Version, "Browser Version Compare");   
			Assert.AreEqual("System.Web.UI.Html32TextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/2.0 (compatible; MSIE 3.02; Windows 3.1)"); 
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("3.02",R.Version, "Browser Version Compare");   
			Assert.AreEqual("System.Web.UI.Html32TextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/2.0 (compatible; MSIE 3.02; Windows 95)");  
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("3.02",R.Version, "Browser Version Compare");
			Assert.AreEqual("System.Web.UI.Html32TextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/3.0 (compatible; MSIE 3.0; Win95)");        
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("3.0",R.Version, "Browser Version Compare");    
			Assert.AreEqual("System.Web.UI.Html32TextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/3.0 (compatible; MSIE 3.01; Mac_PowerPC)"); 
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("3.01",R.Version, "Browser Version Compare");   
			Assert.AreEqual("System.Web.UI.Html32TextWriter",R["tagwriter"],"tagwriter");
		}
		[Test]
		public void Test_IE_4X()
		{
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 4.0; Windows 95)");   
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("4.0",R.Version, "Browser Version Compare");  
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//this one still works but I know it is forged
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 4.0; Windows NT; ....../1.0 )");          
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("4.0",R.Version, "Browser Version Compare");    
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 4.01; AOL 4.0; Mac_PPC)");                
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("4.01",R.Version, "Browser Version Compare");   
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 4.01; AOL 4.0; Windows 95)");             
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("4.01",R.Version, "Browser Version Compare");
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 4.01; AOL 4.0; Windows 98)");             
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("4.01",R.Version, "Browser Version Compare");   
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 4.01; AOL 5.0; Mac_PPC)");                
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("4.01",R.Version, "Browser Version Compare");   
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 4.01; AOL 7.0; Windows 98)");             
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("4.01",R.Version, "Browser Version Compare");   
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 4.01; CS 2000; Windows 98)");             
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("4.01",R.Version, "Browser Version Compare");   
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
		}

		[Test]
		public void Test_IE_5X()
		{
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; MSIECrawler)");          
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("5.5",R.Version, "Browser Version Compare");    		   
			Assert.AreEqual(true,R.IsBot, "Browser Bot Compare");
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0(compatible; MSIE 5.0; Windows 98; DigExt)");                
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("5.0",R.Version, "Browser Version Compare");    
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0(compatible; MSIE 5.5; Windows 98)");    
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("5.5",R.Version, "Browser Version Compare");    
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 5.0; AOL 4.0; Windows 95; DigExt)");      
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("5.0",R.Version, "Browser Version Compare");    
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 5.0; AOL 4.0; Windows 98; DigExt)");      
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("5.0",R.Version, "Browser Version Compare");    
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 5.0; Windows 95)::ELNSB50::00004110032002580314018f000000000502000800000000");        
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("5.0",R.Version, "Browser Version Compare");
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 5.0b1; Mac_PowerPC)");
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("5.0b1",R.Version, "Browser Version Compare");  
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 5.12; AOL 5.1; Mac_PowerPC)");            
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("5.12",R.Version, "Browser Version Compare");   
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 5.5; Windows 98; Win 9x 4.90; UOP IE501)");                
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("5.5",R.Version, "Browser Version Compare");    
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
		}
		[Test]
		public void Test_IE_6X()
		{
			Ocean.Web.HttpCapabilities.Result R;

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; WOW64; SV1; .NET CLR 1.1.4322)");
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");
			Assert.AreEqual("6.0",R.Version, "Browser Version Compare");		
			Assert.AreEqual("true",R["win64"], "Browser win64 Compare"); 
			Assert.AreEqual("1.1.4322",R["clrVersion"], "Browser clrVersion Compare");
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; WOW64; SV1)");
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");
			Assert.AreEqual("6.0",R.Version, "Browser Version Compare");
			Assert.AreEqual("true",R["win64"], "Browser win64 Compare"); 
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");


			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; Win64; x64; SV1)");
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");
			Assert.AreEqual("6.0",R.Version, "Browser Version Compare");
			Assert.AreEqual("true",R["win64"], "Browser win64 Compare"); 
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------			
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; Win64; IA64; SV1)");
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");
			Assert.AreEqual("6.0",R.Version, "Browser Version Compare");
			Assert.AreEqual("true",R["win64"], "Browser win64 Compare"); 
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
		
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------			
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; AOL 4.0; Windows 98)");              
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("6.0",R.Version, "Browser Version Compare");    
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------			
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; AOL 4.0; Windows 98; Compaq)");      
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("6.0",R.Version, "Browser Version Compare");
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
 
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------			
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; AOL 5.0; Windows 98)");              
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("6.0",R.Version, "Browser Version Compare");    
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; AOL 5.0; Windows 98; H010818)");     
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("6.0",R.Version, "Browser Version Compare");    
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------			
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; AOL 6.0; Windows 98)");              
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("6.0",R.Version, "Browser Version Compare");    
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------			
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 6.0; AOL 6.0; Windows 98; {60265C40-F022-11D7-A8DF-0040057B9677})");                  
			Assert.AreEqual("IE",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("6.0",R.Version, "Browser Version Compare");
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
		}

		[Test]
		public void Test_WebTv()
		{
			Ocean.Web.HttpCapabilities.Result R;

			//Mozilla/4.0 WebTV/2.6 Rogers/2.0 (compatible; MSIE 4.0)
			//Mozilla/4.0 WebTV/2.8 (compatible; MSIE 4.0)
			//Mozilla/4.0 WebTV/2.8.1 (compatible; MSIE 4.0)
			//Mozilla/4.0 WebTV/2.8.2 (compatible; MSIE 4.0)

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/3.0 WebTV/1.2 (compatible; MSIE 2.0)");     
			Assert.AreEqual("WebTV",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("1.2",R.Version, "Browser Version Compare");    
			Assert.AreEqual("WebTV",R.Platform, "Browser Platform Compare");  
			Assert.AreEqual("System.Web.UI.Html32TextWriter",R["tagwriter"],"tagwriter");
     
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 WebTV/2.6 (compatible; MSIE 4.0)");     
			Assert.AreEqual("WebTV",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("2.6",R.Version, "Browser Version Compare");    
			Assert.AreEqual("WebTV",R.Platform, "Browser Platform Compare");  
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 WebTV/2.8.2 (compatible; MSIE 4.0)");     
			Assert.AreEqual("WebTV",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("2.8",R.Version, "Browser Version Compare");    
			Assert.AreEqual("WebTV",R.Platform, "Browser Platform Compare");  
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
		}
		[Test]
		public void Test_MSMediaPlayer()
		{
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Windows-Media-Player/10.00.00.3473");     
			Assert.AreEqual("Microsoft Media Player",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("10.00.00.3473",R.Version, "Browser Version Compare");    
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
     
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------						
			R = Browser.Process("Windows-Media-Player/9.00.00.3250");     
			Assert.AreEqual("Microsoft Media Player",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("9.00.00.3250",R.Version, "Browser Version Compare");    
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
			
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------			
			R = Browser.Process("Windows-Media-Player/7.00.00.1440");     
			Assert.AreEqual("Microsoft Media Player",R.Browser, "Browser Name Compare");     
			Assert.AreEqual("7.00.00.1440",R.Version, "Browser Version Compare");    
			Assert.AreEqual("Unknown",R.Platform, "Browser Platform Compare");  
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
			
			/*
			Windows-Media-Player/10.00.00.3473
			Windows-Media-Player/10.00.00.3646
			Windows-Media-Player/7.00.00.1440
			Windows-Media-Player/7.00.00.1442
			Windows-Media-Player/7.00.00.1954
			Windows-Media-Player/7.00.00.1956
			Windows-Media-Player/7.00.00.1958
			Windows-Media-Player/7.01.00.3055
			Windows-Media-Player/7.10.00.3056
			Windows-Media-Player/7.10.00.3059
			Windows-Media-Player/7.10.00.3068
			Windows-Media-Player/7.10.00.3075
			Windows-Media-Player/8.00.00.4477
			Windows-Media-Player/8.00.00.4482
			Windows-Media-Player/8.00.00.4487
			Windows-Media-Player/8.00.00.4491
			Windows-Media-Player/8.00.00.4492
			Windows-Media-Player/9.00.00.2799
			Windows-Media-Player/9.00.00.2800
			Windows-Media-Player/9.00.00.2926
			Windows-Media-Player/9.00.00.2980
			Windows-Media-Player/9.00.00.2991
			Windows-Media-Player/9.00.00.3003
			Windows-Media-Player/9.00.00.3005
			Windows-Media-Player/9.00.00.3008
			Windows-Media-Player/9.00.00.3014
			Windows-Media-Player/9.00.00.3075
			Windows-Media-Player/9.00.00.3093
			Windows-Media-Player/9.00.00.3128
			Windows-Media-Player/9.00.00.3250
			*/
		}
		[Test]
		public void Test_WinCE_1()
		{
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320)"); 
			Assert.AreEqual("WinCE",R.Platform,"Platform");
			  
			Assert.AreEqual("4.01",R.Version, "Browser Version Compare");   
			Assert.AreEqual("Pocket PC",R.MobileDeviceModel, "Browser Version Compare");  
			Assert.AreEqual(true,R.isMobileDevice, "isMobileDevice Compare");
			Assert.AreEqual("Pocket IE",R.Browser, "Browser"); 
			Assert.AreEqual("320",R["screenPixelsHeight"], "screenPixelsHeight"); 
			Assert.AreEqual("240",R["screenPixelsWidth"], "screenPixelsWidth"); 
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
		}
		[Test]
		public void Test_WinCE_2()
		{
					
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; PPC; 240x320; HP iPAQ h6300)"); 
			Assert.AreEqual("WinCE",R.Platform,"Platform");
			Assert.AreEqual("Pocket IE",R.Browser, "Browser Name Compare");   
			Assert.AreEqual("4.01",R.Version, "Browser Version Compare");   
			Assert.AreEqual("Pocket PC",R.MobileDeviceModel, "Browser Version Compare");  
			Assert.AreEqual(true,R.isMobileDevice, "isMobileDevice Compare");
			Assert.AreEqual("320",R["screenPixelsHeight"], "screenPixelsHeight"); 
			Assert.AreEqual("240",R["screenPixelsWidth"], "screenPixelsWidth"); 
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");

		}
		[Test]
		public void Test_WinCE_3()
		{
					
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/2.0 (compatible; MSIE 3.02; Windows CE; 240x320)"); 
			Assert.AreEqual("WinCE",R.Platform,"Platform");
			Assert.AreEqual("Pocket IE",R.Browser, "Browser Name Compare");   
			Assert.AreEqual("3.02",R.Version, "Browser Version Compare");   
			Assert.AreEqual("Pocket PC",R.MobileDeviceModel, "Browser Version Compare");  
			Assert.AreEqual(true,R.isMobileDevice, "isMobileDevice Compare");
			Assert.AreEqual("320",R["screenPixelsHeight"], "screenPixelsHeight"); 
			Assert.AreEqual("240",R["screenPixelsWidth"], "screenPixelsWidth"); 
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
		}

		[Test]
		public void Test_WinCE_4()
		{
				
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; MSIE 4.01; Windows NT Windows CE)"); 
			Assert.AreEqual(true,R.isMobileDevice, "isMobileDevice Compare");
			Assert.AreEqual("Pocket IE",R.Browser, "Browser Name Compare");   
			Assert.AreEqual("4.01",R.Version, "Browser Version Compare");   
			Assert.AreEqual("Pocket PC",R.MobileDeviceModel, "Browser Version Compare");  
			Assert.AreEqual(true,R.isMobileDevice, "isMobileDevice Compare");
			Assert.AreEqual("",R["screenPixelsHeight"], "screenPixelsHeight"); 
			Assert.AreEqual("",R["screenPixelsWidth"], "screenPixelsWidth"); 
			Assert.AreEqual("System.Web.UI.HtmlTextWriter",R["tagwriter"],"tagwriter");
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder CodeProject
Canada Canada
Chris Maunder is the co-founder of CodeProject and ContentLab.com, and has been a prominent figure in the software development community for nearly 30 years. Hailing from Australia, Chris has a background in Mathematics, Astrophysics, Environmental Engineering and Defence Research. His programming endeavours span everything from FORTRAN on Super Computers, C++/MFC on Windows, through to to high-load .NET web applications and Python AI applications on everything from macOS to a Raspberry Pi. Chris is a full-stack developer who is as comfortable with SQL as he is with CSS.

In the late 1990s, he and his business partner David Cunningham recognized the need for a platform that would facilitate knowledge-sharing among developers, leading to the establishment of CodeProject.com in 1999. Chris's expertise in programming and his passion for fostering a collaborative environment have played a pivotal role in the success of CodeProject.com. Over the years, the website has grown into a vibrant community where programmers worldwide can connect, exchange ideas, and find solutions to coding challenges. Chris is a prolific contributor to the developer community through his articles and tutorials, and his latest passion project, CodeProject.AI.

In addition to his work with CodeProject.com, Chris co-founded ContentLab and DeveloperMedia, two projects focussed on helping companies make their Software Projects a success. Chris's roles included Product Development, Content Creation, Client Satisfaction and Systems Automation.

Comments and Discussions