Wednesday, March 11, 2009

Disable UAC on Server 2008 and Vista

I'm running Windows Server 2008 as a workstation. I ran into the usual problems with UAC and eventually disabled it.

My logic is this: On XP we didn't have UAC and I never got into trouble. The reason that I didn't get into trouble is because I'm a highly sophisticated user (software developer). I don't surf dubious web sites or follow suspicious links, and I don't install software from sources that I haven't researched or aren't linked to from multiple reputable places.

I believe that UAC shows it's true value to the mother-in-law (unsophisticated user) and protects them against valid dangers. I have seen my parents clicking on all sorts of links that I wouldn't go anywhere near. They need UAC and it should be switched on for them.

For us developers my belief is that leaving UAC switched on will cost us more in lost productivity than it will gain us in protection.

Disable UAC on Windows Server 2008

 

  1. Open the Control Panel.
  2. Click User Accounts.
  3. Click Turn User Account Control on or off.
  4. (If you receive a User Account Control message click Continue.)
  5. Clear the "Use User Account Control (UAC) to help protect your computer" check box, and then click OK.
  6. Click Restart Now to apply the change right away, or click Restart Later and close the User Accounts tasks window.

Disable UAC on Vista

  1. Similar to the above except when you open the Control Panel just type UAC into the search box (top right).
  2. You will then see the "Turn User Account Control (UAC) on or off. Follow this link.
  3. Clear the check box and then click okay.

 

Friday, March 6, 2009

Streaming a zip file from an ASP.NET web site

I was recently having a really tough time trying to debug the streaming of a zip file from an ASP.NET web app to a browser. The code was fairly simple and is repeated all over the web which gave me confidence in how robust it is:

FileInfo toDownload = new FileInfo(fullFileName);
if (toDownload.Exists)
{
   Response.Clear();
   Response.ContentType = "application/zip";
   Response.AppendHeader("Content-Disposition", "attachment;filename=" +
          toDownload.Name);
   Response.AppendHeader("Content-Length", toDownload.Length.ToString());
   Response.TransmitFile(fullFileName);
   Response.End();
}

The client side error that I was getting was:

Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near 'PK...'.

The good thing about seeing the "PK" in the error is that it told me that the server was indeed sending the zip file. The first two characters in a zip file are PK which is one way to identify a zip file by opening it and reading the first two characters.

The control on the web page that kicked off the download action shown above was inside an UpdatePanel and it was this that was causing the problem. Eilon Lipton wrote the error message above and he explains it in this blog post

The solution it turns out is to put a PostBackTrigger in the UpdatePanel:

<Triggers>
   <asp:PostBackTrigger ControlID="ibDownload" />
</Triggers>

This will force the click to do a regular postback instead of an asyncronous postback and solved the problem.

Wednesday, March 4, 2009

Skewed results

Most web sites collect stats on usage. One of these figures is browser type and version.

I've just been using H&R Block for my tax returns this year and find that their site won't work well with anything other than Internet Explorer (IE). Whenever I get an email from them saying that there's a message I fire up IE to go and check the message.

Now the problem with this is that their stats will show that most of their users are using IE. This is because anybody using them will be forced to use IE. So they will never know which browser their users usually use and thereby creating skewed results for their site usage.

Monday, February 16, 2009

Adding a Canonical Link Element in ASP.NET

Google, Microsoft and Yahoo announced support for a new "canonical" link element in the header of a page that will help clean-up duplicate url's that have been indexed from your site.

The canonical link for this page, for example, would be:

<link rel="canonical" href="http://guyellisrocks.com/coding/adding-a-canonical-link-element-in-asp-net/">

To add this link tag to your header tag programatically using C# add the following to your Page_Load() function:

        protected void Page_Load(object sender, EventArgs e)
        {
            HtmlLink link = new HtmlLink();
            link.Attributes.Add("rel", "canonical");
            link.Attributes.Add("href", "http://guyellisrocks.com/coding/adding-a-canonical-link-element-in-asp-net/");
            this.Header.Controls.Add(link);
        }

 

Friday, February 6, 2009

Why Silverlight is the Future

Rockford Lhotka wrote a good post post yesterday Why Silverlight is the Future.

I'm a Silverlight fan and agree with him. The sheer volume of .NET developers alone make Silverlight a highly likely candidate for success.

One thing that he didn't mention and that I think will push Silverlight to mass acceptance is that it will, at some point in the future, be hostable on mobile devices. Silverlight is just a control (or collection of controls) on a web page. The browser, and the Silverilght runtime/VM host the control. So mobile devices only need a host for Silverlight and then Silverlight will become ubiquitous.

Will Moonlight 2.0 be that host for most mobile devices?

Neil McAllister wrote yesterday The case for supporting and using Mono in which he says:

There's no need to code in C++ for Windows and Objective-C for the Mac -- the same project can be built for either platform from the same C# and JavaScript sources.

And that's the crux of it.

Wednesday, February 4, 2009

Training a text classifier

When writing a text classification system you need to train it. Typically you have a corpus of good data that has been accurately pre-classified and this is what you throw at the system while it is learning the classification.

I came up with what I thought was a good analogy for an untrained text classifier: A genius amnesic. i.e. someone who initially knows nothing but learns lightening fast.

Ultimate Dogfooding

Visual Studio 2010 (VS2010) is being re-written using Windows Presentation Foundation (WPF). I was just listening to Scott Hanselman's 165th podcast in which he interviews Noah Richards about the editor in VS2010. What impresses me is that they're building VS2010 using VS2010. I can only assume that the first couple of builds of VS2010 were done with VS2008 and then I guess that once they had a working version they switched.

This must be the ultimate dogfooding exercise. Building a product using the product.