Scott Hanselman

SmallestDotNet Update - Now with .NET 4 support and an includable JavaScript API

February 9, '10 Comments [15] Posted in ASP.NET | ASP.NET MVC | Javascript | Learning .NET | Microsoft | Source Code | Tools | VS2010 | Windows Client | WPF
Sponsored By

A few years back I wrote a post on the size of the .NET Framework. There's historically been a lot of confusion on the site of the .NET Framework. If you search around on the web for ".NET Framework" or ".NET Framework Redistributable" you'll often get a link to a 200 meg download. That download is the complete offline thing that developers redistribute when they want to install the .NET Framework on any kind of machine without an internet connection.

The .NET 3.5 Client Profile is more like 28 megs and the .NET 4 Client Profile is a looking smaller than that, in fact. Back then I made this website,SmallestDotNet.com to help out. It'll sniff your browser's UserAgent and tell you want version of .NET you have, how big the download would be to get you to .NET 3.5 and what .NET redistributable is best for you in order to minimize your download.

Now that the .NET Framework 4 is coming out soon, I took an hour and updated it (with Tatham Oddie's help, as he's staying over at the house this week) to support the new framework. We also added a few bug fixes (and I'm sure, a few bugs) and a simple Javascript API to help you detect the .NET Framework on the client side.

You can use the site in three ways.

First, visit the site.

If you've got a machine you want to install .NET on, or you're not sure what version it has, just visit SmallestDotNet.com and I'll do my best to tell you. It works best on IE, but it'll also work on Firefox if you've got the .NET add-on. If you've got Safari or Chrome, I'll apologize but I can't help you as those browsers don't tell me anything about .NET.

Second, include the Javascript that spits HTML.

If you want to tell the user what version of .NET they have with minimal effort and you want to do it on your site, perhaps via your blog, you can just include this line:

<script type="text/javascript" src="http://www.smallestdotnet.com/smallestdotnet/javascript.ashx"></script>

and I'll return something like:

document.write('<span class="smallerdotnet">')
document.write('Detected 3.5 SP1 .NET Framework. No update needed.')
document.write('</span>')

and you can style to taste.

Third, include the Javascript that spits JSON.

The HTML spitter is fast, but less useful if you like control over things. Like, um, text. So, you can include:

<script type="text/javascript" src="http://www.smallestdotnet.com/smallestdotnet/javascriptdom.ashx"></script>

and I'll spit out a JSON object like this:

SmallestDotNet = {};
SmallestDotNet.latestVersion = {
major: 4,
minor: 0,
profile: "client",
servicePack: null
};
SmallestDotNet.allVersions = [
{
major: 4,
minor: 0,
profile: "client",
servicePack: null
},
{
major: 3,
minor: 5,
profile: "full",
servicePack: 1
},
{
major: 2,
minor: 0,
profile: "full",
servicePack: null
}
];

We'll put out the latest version of the .NET framework on the machine, as well as its Service Packs, and its profile (client profile, full, etc) if appropriate. It'll also give you an array of ALL the versions of the .NET Framework it finds on the machine. In my example, it says my machine has .NET 4 Client Profile, .NET 3.5 SP1 and .NET 2.0.

UPDATE: I've updated the JSON output to return another array with a complete list of all available .NET Frameworks and the URL they can be downloaded from, something like this:

SmallestDotNet.downloadableVersions =
[{
major: 4,
minor: 0,
profile: 'client',
servicePack: null,
url: 'http://www.microsoft.com/...'
},
...SNIP...

{
major: 2,
minor: 0,
profile: 'full',
servicePack: 2,
url: 'http://www.microsoft.com/...'
},{
major: 1,
minor: 1,
profile: 'full',
servicePack: 1,
url: 'http://www.microsoft.com/...'
}];

I currently don't go into deep deep detail, like .NET 2.0 SP2, etc, but if you want that functionality, let me know and I can add it. This is a spike (ongoing for two years, actually) so if it's useful, let me know. If it's missing something, let me know.

From this JSON, you can ask all sorts of questions. Here's a JavaScript alert() example that would work on this JSON object. Of course, you should check things for null, as well as check the length of allVersions.

alert( SmallestDotNet.latestVersion.major ); 
alert( SmallestDotNet.allVersions.length );
alert( SmallestDotNet.allVersions[0].minor );
alert( SmallestDotNet.allVersions[1].major );");

It'd be cool to add some jQuery love to this and use it to give and end-user some nice feedback on what version of your application to install, or what version of .NET they should install first. It could also be useful for self-troubleshooting your application.

Hope this is useful. Enjoy.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Tuesday, February 09, 2010 6:36:22 AM UTC
Great work Scott, really helpful! I specially loved the message you get when the app detected I already had the 4.0 framework.
Tuesday, February 09, 2010 12:23:54 PM UTC
what about german and other languages on smallestdotnet.com ?
thomas
Tuesday, February 09, 2010 4:01:09 PM UTC
Really nice, Scott. Good job.
PRMan
Tuesday, February 09, 2010 4:44:03 PM UTC
Great Post Scott
Tuesday, February 09, 2010 6:20:52 PM UTC
So internationalization is important, Thomas? For the site text and the js?
Tuesday, February 09, 2010 8:56:50 PM UTC
Great Scott. Thank you.
Tuesday, February 09, 2010 10:18:01 PM UTC
Scott,

Thank you for providing SmallestDotNet and now this extended functionality. Every time I need to setup a server or work on a machine one of the first things I do is Google (sorry) smallest .net and verify the .NET install.

Invaluable.

And on that note, isn't document.write() a no-no now days?
Wednesday, February 10, 2010 12:17:27 AM UTC
Scott,
I would love to see the JSON also providing a list of download links in case I'm not up to date...
The links should be sorted from the smallest to the biggest download.
That way I have everything I need to build my own page without having.
Of course accompanied by the usual major, minor, profile, servicepack describing what it is so that I can tell the user to what he will upgrade if he follows my recommandations...
Because having the version info is one thing but knowing where to find the updates is another...
Thank you...
Wednesday, February 10, 2010 5:06:30 AM UTC
Jonx - I've updated the DOM to support a list of downloadable links, so you can programmatically decide what your user's need and give them the link directly.
Wednesday, February 10, 2010 4:27:56 PM UTC
It would be great if there were a version of the web installer that could be placed on a company's intranet and point to internal locations for the supporting installation files.
John Sinnott
Tuesday, April 20, 2010 7:09:58 AM UTC
It is a good time to update the site(http://www.smallestdotnet.com/) and add more browser support. :)
Tuesday, April 20, 2010 4:42:29 PM UTC
Soeleman - You'd need the .NET Assistant for Firefox if you wanted support for .NET in FF.
Wednesday, April 21, 2010 3:05:37 PM UTC
Hi Scott,

I tried it with FF, and was tellling me : "Detected FireFox. Add .NET Framework 3.5 SP1, only a ~10 meg download.". Should you update it to point to the 4.0 release instead?
Monday, June 28, 2010 8:17:27 AM UTC
Thank you Scott.
Tuesday, September 21, 2010 9:03:36 AM UTC
Great sharing.. Thanks for this Scott!
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.