Click here to Skip to main content
15,881,173 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 557.8K   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
{
	/// <summary>
	/// Summary description for Capabilities_Microsoft.
	/// </summary>
	[TestFixture]
	public class Capabilities_Amiga
	{
		Ocean.Web.HttpCapabilities.Settings Browser;
		Ocean.Web.HttpCapabilities.Result R;
		public Capabilities_Amiga()
		{
			Browser = new Ocean.Web.HttpCapabilities.Settings(Ocean.Web.HttpCapabilities.EmbededFile.BrowserCap);
		}
		[Test]
		public void	Test_AmigaVoyager()
		{
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			Ocean.Web.HttpCapabilities.Result R = Browser.Process("AmigaVoyager/1.0");
			Assert.AreEqual("Voyager",R.Browser, "Browser Name Compare");
			Assert.AreEqual("1.0",R.Version, "Browser Version Compare");
			Assert.AreEqual("Amiga",R.Platform, "Browser Version Compare");
			Assert.AreEqual("AmigaOS",R.OS, "Browser Version Compare");
			Assert.AreEqual(false,R.IsBot, "Browser Version Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("AmigaVoyager/2.95 (compatible; MC680x0; AmigaOS)");
			Assert.AreEqual("Voyager",R.Browser, "Browser Name Compare");
			Assert.AreEqual("2.95",R.Version, "Browser Version Compare");
			Assert.AreEqual("Amiga",R.Platform, "Browser Version Compare");
			Assert.AreEqual("AmigaOS",R.OS, "Browser Version Compare");
			Assert.AreEqual(false,R.IsBot, "Browser Version Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("AmigaVoyager/3.2 (AmigaOS/MC680x0)");
			Assert.AreEqual("Voyager",R.Browser, "Browser Name Compare");
			Assert.AreEqual("3.2",R.Version, "Browser Version Compare");
			Assert.AreEqual("Amiga",R.Platform, "Browser Version Compare");
			Assert.AreEqual("AmigaOS",R.OS, "Browser Version Compare");
			Assert.AreEqual(false,R.IsBot, "Browser Version Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("AmigaVoyager/3.3.122 (AmigaOS/MC680x0)");
			Assert.AreEqual("Voyager",R.Browser, "Browser Name Compare");
			Assert.AreEqual("3.3.122",R.Version, "Browser Version Compare");
			Assert.AreEqual("Amiga",R.Platform, "Browser Version Compare");
			Assert.AreEqual("AmigaOS",R.OS, "Browser Version Compare");
			Assert.AreEqual(false,R.IsBot, "Browser Version Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("AmigaVoyager/3.3.126 (AmigaOS/MC680x0)");
			Assert.AreEqual("Voyager",R.Browser, "Browser Name Compare");
			Assert.AreEqual("3.3.126",R.Version, "Browser Version Compare");
			Assert.AreEqual("Amiga",R.Platform, "Browser Version Compare");
			Assert.AreEqual("AmigaOS",R.OS, "Browser Version Compare");
			Assert.AreEqual(false,R.IsBot, "Browser Version Compare");
		}

		[Test]
		public void	Test_AmigaAWeb()
		{
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			Ocean.Web.HttpCapabilities.Result R = Browser.Process("Amiga-AWeb/3.3; (Spoofed by Amiga-AWeb/3.4APL)");
			Assert.AreEqual("Amiga-AWeb",R.Browser, "Browser Name Compare");
			Assert.AreEqual("3.3",R.Version, "Browser Version Compare");
			Assert.AreEqual("Amiga",R.Platform, "Browser Version Compare");
			Assert.AreEqual("AmigaOS",R.OS, "Browser Version Compare");
			Assert.AreEqual(false,R.IsBot, "Browser Version Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Amiga-AWeb/3.4");
			Assert.AreEqual("Amiga-AWeb",R.Browser, "Browser Name Compare");
			Assert.AreEqual("3.4",R.Version, "Browser Version Compare");
			Assert.AreEqual("Amiga",R.Platform, "Browser Version Compare");
			Assert.AreEqual("AmigaOS",R.OS, "Browser Version Compare");
			Assert.AreEqual(false,R.IsBot, "Browser Version Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Amiga-AWeb/3.4; (Spoofed by Amiga-AWeb/3.4APL)");
			Assert.AreEqual("Amiga-AWeb",R.Browser, "Browser Name Compare");
			Assert.AreEqual("3.4",R.Version, "Browser Version Compare");
			Assert.AreEqual("Amiga",R.Platform, "Browser Version Compare");
			Assert.AreEqual("AmigaOS",R.OS, "Browser Version Compare");
			Assert.AreEqual(false,R.IsBot, "Browser Version Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Amiga-AWeb/3.4APL");
			Assert.AreEqual("Amiga-AWeb",R.Browser, "Browser Name Compare");
			Assert.AreEqual("3.4",R.Version, "Browser Version Compare");
			Assert.AreEqual("Amiga",R.Platform, "Browser Version Compare");
			Assert.AreEqual("AmigaOS",R.OS, "Browser Version Compare");
			Assert.AreEqual(false,R.IsBot, "Browser Version Compare");
		}

		[Test]
		public void	Test_AmigaChimera()
		{
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; AmigaOS; Chimera)");       
			Assert.AreEqual("Chimera",R.Browser, "Browser Name Compare");
			Assert.AreEqual("0.0",R.Version, "Browser Version Compare");    
			Assert.AreEqual("Amiga",R.Platform, "Browser Platform Compare");
			Assert.AreEqual("AmigaOS",R.OS, "Browser OS Compare");
			Assert.AreEqual(false,R.IsBot, "Browser Bot Compare");

		}
		[Test]
		public void	Test_AmigaIBrowse()
		{
			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("IBrowse/2.3 (AmigaOS 3.9)");                        
			Assert.AreEqual("IBrowse",R.Browser, "Browser Name Compare");
			Assert.AreEqual("2.3",R.Version, "Browser Version Compare");    
			Assert.AreEqual("Amiga",R.Platform, "Browser Platform Compare");
			Assert.AreEqual("AmigaOS 3.9",R.OS, "Browser OS Compare");
			Assert.AreEqual(false,R.IsBot, "Browser Bot Compare");

			//-------------------------------------------------------------------
			//
			//-------------------------------------------------------------------
			R = Browser.Process("Mozilla/4.0 (compatible; IBrowse 3.0; AmigaOS4.0)");
			Assert.AreEqual("IBrowse",R.Browser, "Browser Name Compare");
			Assert.AreEqual("3.0",R.Version, "Browser Version Compare");    
			Assert.AreEqual("Amiga",R.Platform, "Browser Platform Compare");
			Assert.AreEqual("AmigaOS 4.0",R.OS, "Browser OS Compare");             
			Assert.AreEqual(false,R.IsBot, "Browser Bot Compare");
		}
	}
}

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