Client side .Net Framework version

Dearl All,

I have got a windows form embedded into a web application which requires .Net Framework 2.0 on the client end.

Now my question is that how can I check if the client has .Net Framework installed or not and also which version it is? 

Thanks 

0
UmerTahir
11/19/2007 2:14:41 PM
asp.net.client-side 24353 articles. 1 followers. Follow

13 Replies
1060 Views

Similar Articles

[PageSpeed] 21

You can check it through javascript from web app. .NET embeds its version information to IE user agent. So, in IE you can check for .NET with window.navigator.userAgent. For example use the following line in JavaScript to detect .NET 2.0:

if (window.navigator.userAgent.indexOf(".NET CLR 2.0") != -1)

{

// some code goes here

}

or you can use a simple regular exression to get versions info.

IE userAgent sample: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; SLCC1; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.5.20706; .NET CLR 3.0.590)

0
Rubo
11/19/2007 4:23:49 PM

Rubo:

You can check it through javascript from web app. .NET embeds its version information to IE user agent. So, in IE you can check for ..NET with window.navigator.userAgent.

 

I am not much familiar with javascript, is there any sample code available for what you have suggested?

 

Thanks 

0
UmerTahir
11/19/2007 4:34:02 PM

Here is a sample code to detect .NET version in IE:

<script type="text/javascript">
if
(window.navigator.userAgent.indexOf(".NET CLR 2.0") != -1)

    alert(".NET Framework 2.0 is installed.");

else

    alert("You have to install .NET Framework 2.0 and above.");

</script>

0
Rubo
11/19/2007 5:03:01 PM

U can also get it from the Server variables.

If u fire a url from the browser, u can find the client details like Client OS, Client Browser version and so many .....................

Just enable Trace="true" , U can see a lot of client information below the web page.

Request.ServerVariables["HTTP_USER_AGENT"]


Cheers,
Rajesh
0
grajeshkreddy
11/20/2007 2:06:39 AM

I have tested the above code on two machines, one which have .Net 2.0 installed on it and the other one whihc doesn't have.

 The system which have .Net 2.0 installed displays the alert message: .NET Framework 2.0 is installed.

But the other PC which doesn't have  .Net framework 2.0 on it won't show any alert at all.

Code is not going to the else part, any quick fix to it?

 

Thanks 

Rubo:

Here is a sample code to detect .NET version in IE:

<script type="text/javascript">
if
(window.navigator.userAgent.indexOf(".NET CLR 2.0") != -1)

    alert(".NET Framework 2.0 is installed.");

else

    alert("You have to install .NET Framework 2.0 and above.");

</script>

 
0
UmerTahir
11/20/2007 10:49:49 AM

Sorry for being ignorant, but from where would I find the option Trace="True" ?

 

cheers 

 

grajeshkreddy:

U can also get it from the Server variables.

If u fire a url from the browser, u can find the client details like Client OS, Client Browser version and so many .....................

Just enable Trace="true" , U can see a lot of client information below the web page.

Request.ServerVariables["HTTP_USER_AGENT"]

0
UmerTahir
11/20/2007 10:56:57 AM

In page attribute you have to add the trace

<%@ Page.... Trace="true"  %>

 


N.P.Senthil
Software Engineer
0
nps
11/20/2007 11:01:11 AM

 now how can I make the else part work guys:

 
<script type="text/javascript">
if (window.navigator.userAgent.indexOf(".NET CLR 2.0") != -1)

    alert(".NET Framework 2.0 is installed.");

else

    alert("You have to install .NET Framework 2.0 and above.");

</script>
 
  
0
UmerTahir
11/20/2007 11:46:29 AM

for the following code:

HTTP_USER_AGENT server variable =  <%= Request.ServerVariables("HTTP_USER_AGENT") %> <BR> 
Client's browser is shoing the following string: 
 HTTP_USER_AGENT server variable = Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 
5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)

Now  I am only interested in the last bit: NET CLR 2.0

How can the above query be tailored in javascript toget the version of .NetFramework?

 

grajeshkreddy:

U can also get it from the Server variables.

If u fire a url from the browser, u can find the client details like Client OS, Client Browser version and so many .....................

Just enable Trace="true" , U can see a lot of client information below the web page.

Request.ServerVariables["HTTP_USER_AGENT"]

 
0
UmerTahir
11/20/2007 12:24:56 PM

You can detect it on server side as well as on client side using IE (!) user agent string. I see no need to tailor JavaScript code and server-side code in this case. On server side you can put the following code into the Page_Load event handler to detect .NET on client side:

if (Request.UserAgent.IndexOf(".NET CLR 2.0") != -1)

{

    // everything is alright

}

else

{

    // warn user to install .net framework

}

0
Rubo
11/21/2007 10:30:50 AM

Request.UserAgent.IndexOf(".NET CLR 2.0") does not detect .Net Framework because I did the following changes to it and it still went into the IF part:

 

if (Request.UserAgent.IndexOf("Test Client") != -1)

{

    // everything is alright

else

{

    // warn user to install .net framework

}

 

0
UmerTahir
11/21/2007 10:37:48 AM

Probably because you left off the bottom bracket in your code, because it works for me this way:
if ( Request.UserAgent.IndexOf("Test Client") != -1 )
{
    // everything is alright
}
else
{
    // warn user to install .net framework
}

Just curious, but why would you worry if the client has the Framework installed?

NC...

 

0
NC01
11/21/2007 9:37:49 PM

 oh yes, bracket solves the case.

The reason why I wanted to detect the version of .Net framework on client's end is because the windows application, embedded into a web application, only runs on version 2.0.

Thanks  for your reply.

0
UmerTahir
11/22/2007 11:15:44 AM
Reply: