Scott Hanselman

The .NET Framework and the Browser's UserAgent String

September 11, '08 Comments [42] Posted in ASP.NET | Programming
Sponsored By

Vote Now! One of the things I'd said I'd do, Dear Reader, when I went to work for the Big Blue Monster, was to get your feedback into The Company whenever possible. Here's another opportunity for us to effect change, however small.

A while back I made a little site called http://www.smallestdotnet.com that would look at your Browser's UserAgent

and let you know the size that the latest .NET Framework would be for you (ballpark size). In the process I've gotten to see a LOT of interesting Browser UserAgents in the IIS logs.

If you visit the site and scroll down, you'll see YOUR Browser UserAgent at the bottom. Here's mine:

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.5.21022; Media Center PC 5.0; Zune 2.5; MS-RTC LM 8; .NET CLR 3.0.30618)

Notice that I've got IE8 on 64-bit Windows. However, there's other stuff in there, like I have the Zune software, I have Media Center enabled, and I've got three versions of the .NET Framework. In this example, 2.0, 3.0, and 3.5.

Here's a UserAgent that showed up today on http://www.smallestdotnet.com:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 1.0.3705; InfoPath.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 1.1.4322; .NET CLR 3.0.04506.590; .NET CLR 3.5.20706; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022; Zune 2.5; WWTClient2; MS-RTC LM 8; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)

Now, this guy is clearly a developer who has installed beta versions of things, but he's also got InfoPath and a bunch of other stuff. Still, that's a pretty crazy UserAgent and it's being transmitted all the time.

Registry Editor

UserAgents are added for IE in the Registry, as seen in the screenshot above.

Why Should You Care?

In the case of a system with IE and a lot of .NET Framework versions, ASP.NET currently truncates the UserAgent at 256 characters so my own case, the site was only getting part of the story. They might change that truncation number, but ultimately, I think we all want tidy UserAgents, right?

UserAgent length matters. Early versions of FireFox had a UserAgent Limit of 127 characters and used to return null before the bug was fixed last month and now it truncates. The FireFox plugin added when you installed .NET by default only shows the most recent .NET Framework. Do you want that functionality in .NET?

Truncated UserAgents can also mean you might get "Unknown" Back from Request.Browser.Browser. In my case, I was getting an exception from Request.Browser.ClrVersion because the truncated CLR Version was something like ".NET CLR 3.".

There's some people looking at this internally, and there's three groups involved. There's Internet Explorer, involved peripherally, there's the CLR Team and the installer that adds the values, and there's the ASP.NET team who cares because of the server-side sniffing.

Poll/Questions

Vote Now!The questions I have for you are these:

  • Do you use these .NET Framework-specific values? What for? How do they improve your site or make your user experience different?
  • If the .NET Framework-specific values were removed completely what would that mean to you or your business?
  • What if the values were conflated to show just the most recent .NET Framework?
    • Could you get the information you needed using just the value of the latest version?
  • What if the values were conflated to show just the major side-by-side CLR releases?
    • For example, 1.x, 3.5SP1 and 4.0. In that example, 3.5SP1 implies 2.x and 3.0. If you just had 2.0, you'd see 1.x, 2.0, and that'd be it.
    • Could you get the information you needed using just the value of the those major CLR/Framework versions?

Please take a moment and do this micropoll. It's ONE question with ONE vote button. Literally two seconds of your time. You can also add the poll to your blog. Also, leave comments and I'll make sure the right people seem them.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is 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 SherWeb

Microsoft IE8 and Google Chrome - Processes are the New Threads

September 9, '08 Comments [52] Posted in Tools
Sponsored By

I happened to install Google Chrome (Alpha) the same day I installed Internet Explorer 8 (Beta). I noticed immediately, as I'm sure many of you have, that both browsers isolate tabs in different processes.

Unix folks have known about the flexibility of forking a process forever. In Unix, fork() is just about the easiest thing you can do. Also, fork()ing in Unix will copy the whole process and all variables into a new space. Everything after the fork happens twice. Multitasking made easy.

In Windows, you call CreateProcess() and you don't get a copy or clone. You just start up a whole new universe, starting from the very beginning - NOT from the call to CreateProcess().

What processes in Windows and Unix do have in common is that they each get their own protected virtual memory space. They are all alone and isolated. If a process crashes it's less of a crisis than if a thread within a process crashes.

(In .NET, AppDomains are like mini-processes, but they just aren't as completely isolated as a process is, so you can still bork an AppDomain enough that the whole process dies.)

Why does all this matter? Well, back in the day, most folks on Windows would recommend that developers interested in multi-tasking use threads. There's even been talk about fibers (really tiny threads within threads...like superstrings ;) ) However, darnnit, processes are easy.

Ah! But they're slow! They're slow to start up, and they are slow to communicate between, right? Well, kind of, not really anymore. There's this thing called Moore's Law that keeps marching on. Making a new process and talking to it in any of the myriad IPC (Inter-process Communication) methods available just isn't that much of a problem these days. Just open up Process Explore and enter "Tree View" sometime to see how many programs you use every day are actually multiple .exe's working together.

You can learn more about IE8 and how their multiple-process model works in both IE7 and IE8. (IE7 had this process isolation feature also...except one tab per security zone.)

You can learn more about Chrome and how they talk between their multiple "Render" processes in this architectural overview. They are using named pipes if you were wondering how Chrome talks to itself.

Tab/Process Isolation

I'll open up an instance of IE8 and open one tab with cnn.com and other with hanselman.com. I'll do the same with Google Chrome. Here's what Process Explorer shows.

Picture of the Process Tree in Process Explorer 

Why are some of the processes brown? Those are jobs, a new kind of process added in Windows 2000. Jobs are made with CreateJobObject and AssignProcessToJobObject. You can also get a Job using CreateProcess as unless you specify the CREATE_BREAKAWAY_FROM_JOB flag. Jobs in Windows can be controlled as a group and resource limits can be set on them. You can learn more about Jobs and why they can be more secure up on MSDN.

Crash Protection

The whole point of having more than one process for a browser is for crash protection. I've had every browser I've ever used crash in one tab while I was hoping to keep my other 49 tabs open.

Let's blow away some processes manually and see what the browsers do. I'll blow away the non-job process for Chrome.exe.

Chrome with a Sad Plugin face

Looks like that process hosted Flash. See how the Flash object has been replaced on the cnn.com home page with a sad puzzle piece? Cool. Chrome hosts plugins in their own process also.

Lets blow away another Chrome.exe process. Ah, looks like that particular process was rendering hanselman.com. It's been replaced by a sad-page icon.

Scott Hanselmans Computer Zen - Google Chrome (2)

OK, let's blow away an IE8 process....

Balloon Help in IE8 telling me that a tab has been recovered

Ah, looks like the FIRST time a page crashes in IE8, it dumps the process, the tab disappears, then the tab comes back automatically to try to put the user where they were before. I'll kill the new process...

Website restore error - Windows Internet Explorer

Looks like IE8b2 will only try a few times to automatically restore the bad tab then it gives up and gives its equivalent sad-tab and says "the website continues to have a problem." Also cool. This beta includes an option to turn "automatic crash recovery" off or on.

If the parent process dies (or, in this case, I kill it myself!) then I'll get a dialog from IE8 offering to restore the last session.

Windows Internet Explorer

I'll get this similar message in Google Chrome.

image

Very cool. Now I have two browsers that I can open up a buttload of tabs in and not worry about maxing-out process limits or having one bad tab messing up the whole bunch.

PS: If you are poking around in Chrome, try visiting pages like: "about:network", "about:stats", "about:dns" and "about:memory"

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is 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 SherWeb

Firefox, ClickOnce, XBAPs and .NET 3.5 SP1

September 5, '08 Comments [3] Posted in ASP.NET | BabySmash | Musings | Tools | Windows Client | WPF
Sponsored By

One of the things that I noticed immediately when I made the SmallestDotNet was that Firefox was reporting the version of the .NET Framework installed. There's a Firefox extension that is installed with .NET 3.5SP1. I was stoked about this because I'd like users of BabySmash to be able to use ClickOnce from Firefox to launch it.

ClickOnce and Firefox

When you install .NET Framework 3.5SP1, there's a key written to the registry whether Firefox is installed or not. If Firefox is installed later, it will notice the key and use the plugin. If it's already installed, it'll just work. The registry key points to a Firefox Extension (XPI) that acts like the 3rd party FFClickOnce extension that a lot of us installed before.

The registry key is at HKLM:\Software\Mozilla\Firefox\Extensions This Firefox Addin helps ClickOnce applications work from inside of Firefox 2 or Firefox 3. It'll be installed with any installation of .NET 3.5 SP1, including the smaller Client Profile.

The add-in looks like this...

Picture of the Firefox Addins dialog

And its options dialog looks like this:

image

On my system the Firefox UserAgent now looks like this:

Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1 (.NET CLR 3.5.30729)

By default, as you can see in the dialog, the browser will report just the most recent version of the .NET Framework unless you say otherwise.

What happens if the FFClickOnce extension is already installed?

In Firefox 3 the FFClickOnce add on will automatically get disabled as it has not been updated.

In Firefox 2 the FFClickOnce extension does not alter the user agent string due to a safeguard against creating a user agent greater than 128 characters.  What happens when the user clicks on a .application link is dependent on the user’s configuration.

For Firefox 2.0 this is the table of possible prompting/launching configurations.  The default for each add-on is marked in bold. 

.NET Assistant FFClickOnce Result
No Prompt Prompt FFClickOnce prompts and handles the click
No Prompt No Prompt FFClickOnce handles the click
Prompt Prompt

.NET Assistant prompts and handles the click

Prompt No Prompt

FFClickOnce handles the click

When both add-ons are in the default configuration the user will get the FFClickOnce prompt and click once activation will follow the FFClickOnce path which may bypass IE download policy.  In all cases the normal ClickOnce UI will be shown.

What this all means is that ClickOnce will work in FireFox 2 and 3, whether FFClickOnce is installed or not.

How's it done?

The plugin is written with standard XUL (pronounced zoo-el) via XML and JS.

As an aside, I think it's cool that the XML namespace for XUL is:
http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul

You can go find the plugin yourself in:

C:\Windows\Microsoft.NET\Framework\v3.5\Windows Presentation Foundation\DotNetAssistantExtension

It's a .jar file, and you can copy it out and rename it .zip and open it up. The basic gist is that the plugin watches for a particular MIMEType and application, and if it matches, it launches the ClickOnce application using the the .NET Framework's PresentationHost.exe.

isClickOnce: function()
{
var mimeInfo = dialog.mLauncher.MIMEInfo;

// Checking the file extension may be second guessing the webserver
// but when 'prompt' is set the user will still have a save button.
if (mimeInfo.MIMEType == "application/x-ms-application" ||
mimeInfo.primaryExtension == "application")
{
return true;
}

return false;
},


launch_application: function()
{
this.execute(this.getSystem32Dir() + \\PresentationHost.exe,
"-LaunchApplication " + dialog.mLauncher.source.spec);

dialog.mDialog.close();
}

It's not too complex, and it's sure nice that BabySmash users can use ClickOnce to launch the smash.

XBAP

XBAPs, or XAML Browser Applications are also enabled in Firefox in .NET 3.5 using the standard NPAPI browser plugin API. The NPWPF.dll enables XBAPs under Firefox.

Image of the NPWPF.dll that enables XBAPs

XBAPs are WPF applications that run inside the Browser's Chrome. They're good for Intranet applications where you want really easy deployment, the complete .NET Framework (as opposed to Silverlight) and a browser's navigational model.

If you type in about:plugins in Firefox, you can get a list, including this one:

The about:plugins page in Firefox 

Notice the MIME Types that this plugin has registered for and the extensions (suffixes) it handles. Each of these plugins are automatically installed and enabled when you install the .NET Framework 3.5SP1, so you can count on them.

Thanks to Eric Harding, Troy Martez and Jennifer Lee for helping me pull this information together. They're going to be adding more content to the Windows Client website very soon with more details how for developers to package and use the .NET Client Profile. They'll also be releasing lots of documentation and details on ClickOnce and deployment improvements in the framework. I'll point you to everything I can dig up, Dear Reader, as soon as I can.

Related Links

Technorati Tags: ,

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is 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 SherWeb

Family Calendar Management - Sharing Life between Outlook and Web Calendars and the Magic of iCalendar

September 5, '08 Comments [7] Posted in Musings | Tools
Sponsored By

Recently while talking to a friend I said something like "Oh, yes, my wife send me a meeting request for that." My friend was shocked. "How did you get your wife to send you Outlook Invites?" they said.

I was surprised they thought it was a big deal that we might manage our lives and appointments the same way a business runs their meetings. Why manage one's calendar with attention and detail at work, the use a Post-It Note or a Dry Erase board at home? Each to his or her own, to be sure, but ultimately find a system that works for you.

Don't give me the standard "Wow, that's a lot of work to set this up" comments. This took all of 10 minutes to do, I'm just being extra detailed for those who like their instructions along with pictures, clear steps and a little philosophy and history.

Here's what works for us and how we set it up. I talked about it in Podcast 58 on Synchronizing Your Internet Calendars.

Basics in a Nutshell

This is the setup my wife and I have. I sync portions* of my calendar with a web calendar. Each of us can see each other's calendars as she subscribes to that calendar. My Outlook is my work email address, and I also have my personal email. She can send me Meeting Invites to either account. When I accept them, they'll show up in both places.

Diagram showing how my calendars sync

On Calendar Sharing

I'm using Outlook and The Wife is using Google Calendar, so this post uses those two products as an example. That's useful because they are both very common, and the combination is common. Also, it's nice to see Microsoft Products working with non-Microsoft Products using Open Standards.

However, the most important philosophical point to get from this section is that whatever service you are using, make sure you pick one that allows you to have control over your data and how it's published. Data Portability is important. You want to make sure you can get your data in and out of your chosen store. Preferably that'll be using a format like iCalendar (RFC 2445). Just knowing that the standard exists is empowering, because now you know what to look for.

Sharing (Publishing) in Outlook 2007

In Outlook, there's two kinds of Calendar "sharing." There's Sharing and Publishing, in fact. Sharing in Outlook language means to Share your Calendar internally to your company's Exchange Server, while Publishing means to send your Calendar out to the Internet. By default this means to calendars.office.microsoft.com, but it can mean elsewhere.

TIP: I put my Free Busy info at http://www.hanselman.com/freebusy which just redirects to the Office site. This makes it easy for others to schedule meetings with me without giving away personal information or calendar details. I just publish free/busy time.

image

You CAN, if you like, publish your calendar out to the Internet as an ICS file, also called a "webcal" and then have other calendars pull from that. However, I prefer to have more control over what I publish, as I've got work meetings and things I may not want out of my Outlook.

SyncMyCal or Google Calendar Sync

I want to part (or all) of my calendar into my wife's calendar. She uses Google Calendar, and I've got a Google Calendar using my personal email address.

In order to get my appointments into Google Calendar, I prefer to use SyncMyCal software (I paid $25 for it). There is another free tool from Google called Google Calendar Sync but it's VERY basic. I prefer SyncMyCal (enough to pay for it). It's an addin that runs inside of Outlook and it supports multiple calendars, can sync a specific Outlook category (like just Personal events), does date-range-filters, and will sync Contacts if you like.

Public Calendars and Subscribing to Calendars in Outlook

There's lots of sites that have lists of events and calendars. The best of them, like Upcoming.org include webcal/iCal/xCal feeds for all the events. Most personal web-based calendaring systems like Google Calendar (and my wife's calendar) have URLs that you can subscribe to.

image

For example, the Subscribe button on the Upcoming site includes an iCal option. These URLs look like:

webcal://upcoming.yahoo.com/calendar/v2/search_all/?search_placeid=RlEYPWubBZtlFXkb&rt=1

Even though they have webcal:// at the beginning, they are still serving the calendars over HTTP. However, the webcal:// "psuedo-protocol" is a hacky way to get something to happen when you click on it. Because I have Outlook installed, clicking that iCal link gets me this dialog:

Microsoft Office Outlook

Clicking yes adds a new calendar to Outlook in "Other Calendars."

image

This is how I add all sorts of calendars into Outlook. I've got Team Calendars from Sharepoint, Calendars from our Intranet, as well as the wife's.Any calendar can be viewed side-by-side with the main.

Picture of my Outlook Calendar side-by-side with another

Or, I can overlay them. This is really useful for viewing The Wife's calendar and finding time where we can both free. The secondary calendar appears "ghosted" and overlaid over the primary. You can even show multiple (6, 7, etc) calendars and easily find time for meetings amongst your teammates.

Picture of my Outlook Calendar overlaid with another

Consuming Web Calendars from inside Google Calendar

If you've got a calendar "in the cloud" with a URL to an ICS, it's easy to add them to Google Calendar. In Calendar click "Add" under Other Calendars and click "Add By Url":

image

This is where you'd paste in the iCal URL for the calendar you're trying to consume. The wife does this with public calendars. For family there's a faster way. Just click on your calendar and click "share this calendar" and Google takes care of the rest.

IMPORTANT NOTE and CYA DISCLAIMER: It's ironic that while I've been using various plugins for Outlook Calendar synchronization for the last four+ years and never lost a thing, this week while on a trip (and while writing this post) I lost (almost) all my future appointments. Because I'm using SyncMyCal along with three different other experimental plugins, not to mention syncing with Mobile Devices, my gut says it's not SyncMyCal. However, this near-data loss is an important reminder that there's always a chance you can lose something important when you're using any synchronization software that syncs deletes. 

I got my data back by going to another machine I had with Outlook on it, launched Outlook and immediately put it into Offline mode so the deletes from the server wouldn't come down. I exported that range of missing appointments from that machine and imported them to another. The final calendar was then updated in Exchange. Crisis averted, but it was a scary time. If you lose your data, I can't help you. Be careful.

* filtering out private/sensitive/NDA work meetings via categories

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is 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 SherWeb

Skyping the Wife: Foolproof Video Conferencing with Your Family While on the Road

September 5, '08 Comments [9] Posted in Musings | Remote Work | Speaking | Tools
Sponsored By

I really like presenting and traveling around and meeting people, but I just hate being away from my kids. It's visceral. It's physically painful. I bring them whenever I can, but during this last trip to New Zealand and Australia it wasn't possible and I was away for 8 days. Almost killed me.

Since I work from home, when I need to talk to folks in Redmond I use Office Communicator, sometimes ooVoo if we need to talk to multiple people, or sometimes a Roundtable. Roundtables are cool because you get a full 360 degree view of the room.

panaroma

Using Video Conferencing has become totally fundamental to my work life, and when I travel (a few days a month) it's utterly indispensable.

I've traveled a few times and tried to call the wife via Video Conferencing and had an utter failure. We've had trouble with her figuring out how to answer the call, how to run the app, login, deal with odd dialogs, updates, and all the general gremlins that can potentially take what is supposed to be a great experience and turn it into long-distance tech-support. Nothing lowers the WAF (Wife Acceptance Factor) like telling your wife to crawl under the computer desk and check the microphone cables.

I watched literally three different technical speakers try to get video conferencing work while in the speaker room on this last trip. One succeeded. All the others got themselves into situations where the spouse could IM, but not hear, or hear but not see, or whatever. "Can you hear me now?"

Foolproof Familial Video Conferencing

After a half-dozen failures I finally got smart. Here's what I ended up doing to make it easy. This has worked for my wife and I nine out of ten times (once there were connectivity problems at the hotel) and it's worked from Europe to the South Pacific.

Step 1 - Hardware

Get a good camera. I recommend the LifeCam VX- or NX- series. The VX-7000 is nice and simple for home. It has a good microphone built-in and the camera will do 640x480 at 20+fps easily.I use the NX-6000 for my laptop.

Step 2 - Software

Download Skype (or ooVoo or Live Messenger). You'll need two accounts, one for you (the techie) and one for your spouse. Personally I recommend a dedicated account for trips for your spouse. Something with a username like "ScottIsTraveling."

Step 3 - Preparation before you travel

Before you travel, declare one machine in the house that video conferencing machine. Log the spouse into the special travel account. Add your account as a Contact to the special travel account. That means that the special account will have only one friend - you. This is important.

Next, go into Options (I use Skype as an example, but hopefully other apps have similar options) and into Privacy. Set the options such that these are true:

"Only allow people who are in my contact list to contact me"

and

"Automatically answer calls from people who are in my Contact List"

and finally, and most importantly:

"Automatically Send Video"

These are the magic three options. With this setup, your spouse will have one contact, you, and when you call it will be auto-answered and the video will start.

Then I leave the account logged in and I check the video camera and microphone before I go.

img016

This allows me to call the house and have video start without the wife even touching the machine. Daddy can show up on the computer and say "Hi! It's me, is anyone there!?" My son can run it and start talking to me, even without Mommy's help.

One last tip, try to use whatever the highest resolution your camera, bandwidth, and software supports. I was able to get near-DVD quality (640x480) this last trip and was thrilled with the quality. Video conferencing has come a long way since my first black-and-white Logitech QuickCam.

Next time you're traveling I encourage you to try this out and see how it goes. This trip I was able to have chats with the family every night with no glitches or troubles. It almost made the time away tolerable.

Technorati Tags: ,,

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is 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 SherWeb

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