Did you know that Text Control's US office is in Charlotte, NC?
Call your sales representative at: +1 704-544-7445.

TX Text Control Blog

Björn MeyerASP.NET: Getting the client's .NET version

Blogged by Björn Meyer on September 19, 2007 and tagged with browsertextcontrol.

To use TX Text Control Server for ASP.NET (incl. Windows Forms)'s BrowserTextControl in the Internet Explorer, the .NET Framework must be installed on client-side. A client-side control is required to provide the true WYSIWYG editing interface.

If no .NET Framework is installed, you might redirect your users to a download and install page for all prerequisites.

If you want to avoid external controls or Javascript to check whether a .NET Framework is installed, there is only one way to get this information from the client: Using the user agent information the browser discloses. Using the HTTP server variables, a string can be requested that describes the browser in detail.


This returns a string like this:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.04506; .NET CLR 1.1.4322; InfoPath.1)

It shows that my machine is running Windows Vista (NT 6.0), I am browsing with Internet Explorer 7.0 and that 3 versions of the .NET Framework are installed: 1.1, 2.0 and 3.0.

Now, we simply need to split the returned string to get the specific versions.

ArrayList agentVariables = new ArrayList(Request.ServerVariables["HTTP_USER_AGENT"].Split(';')); foreach (string variable in agentVariables) { if (variable.StartsWith(" .NET")) ListBox1.Items.Add(variable.Trim()); }

The above code fills a list box with the available .NET Frameworks.

User Contributed Note

User Contributed Note by ASP.NET Applications on October 24, 2007 at 3:47:12 PM CEST

Great Blog Good example.
User Contributed Note

User Contributed Note by Arif Azim on April 16, 2009 at 10:20:53 PM CEST

Hi, You can also take easier route to get clientside .net version. Here it is, if (Request.UserAgent.IndexOf(".NET CLR 2.0") != -1) { "Installed"....... } else { "Not installed"......... }

Add note

Call us: +1 704-544-7445 (United States)





Buy Now

About Text Control

Founded in 1991, Text Control is an award-winning Visual Studio Industry Partner and leading vendor of word processing and reporting components for Microsoft development technologies. The products help thousands of developers add comprehensive word processing functionality to their applications. Text Control is 100% self-owned and independent of all investor decisions. Customers benefit from these years of experience, large user-base, and at the same time, appreciate developing with a mature, reliable product.

TX Text Control logo

The TX Text Control logo is a registered trademark in the United States, Europe and other countries.