Funnily enough, you can’t run ASP.NET without ASP.NET.

ASP.NET sites not working

I wasted a few hours tracking down an issue the other day where I couldn’t get an ASP.NET website running on a fresh install of Windows 7 and VS 2010. This website was running on my previous install, making it very frustrating. I spent a lot of time running through event log red herrings before coming across the real solution to my problem.

This problem can manifest itself in a number of ways:

  • You get an error that indicates that ASPX files are mapped to a static file handler
  • You have multiple versions of the framework installed, your site gives a 404, and you get errors/warnings in the eventlog along the lines of “Unable to find schema for config section 'system.web.extensions/scripting/scriptResourceHandler'“, “Unknown attribute 'type'” where these errors come from the web.config of the web application you’re trying to access.

There are other possibilities for these errors, but a big possibility is that particular version of the .NET framework that your application is not registered in IIS. The most common reason for this is that you install IIS after the framework is installed. Obviously the installer can’t do the business when IIS isn’t around.

Note: you can have the correct framework selected in the IIS application pool settings, and your web.config can be perfect but you may still be experiencing this error.

IIS looked right to me, but it wasn’t finding squat. You may not see the ASP section for the website if no framework version is installed, but if say, .NET 4 is configured, and the 3.5 version that comes with 7 isn’t, your 3.5 sites will mysteriously fail. What fun!

The magic application that allows you to diagnose whether this problem is affecting you is aspnet_regiis.exe. This little tool is found in the framework install folder. Importantly, and counter-intuitively, to check the status of a particular framework version, you need to run the executable that is specific to that version of the framework. For example, to check 1.1, you need to open a command prompt and change to the %windir%\Microsoft.NET\Framework\v1.1.4322 folder.

To check that the framework is installed, run the command: aspnet_regiis -lv.

To install this version of the framework, use aspnet_regiis -ir. This installs the framework version, but doesn’t change the settings of existing IIS application pools.

See the reference topic: ASP.NET IIS Registration Tool (Aspnet_regiis.exe) on MSDN for more information.


Sorting with LINQ: don’t use anonymous types

I got the error message “System.ArgumentException: At least one object must implement IComparable.” today for the following, seemingly innocuous code. var ordered = order.Lines.OrderBy(l => new { l.AdminCode, l.OrderLineNr}); I thought this was the way to do it; after, that’s the way that you use Join() for multiple properties. What it was however was a


Using asymmetric properties in views

Many people separate their business logic and view classes into two or more separate assemblies. This gives rise to the ability to use an asymmetric set for view properties that aren’t meant to be accessible. Simply put: public string SomeProperty { get; internal set; } The internal modifier means that this property is only accessible


Google Docs API: get all spreadsheets/docs in a folder

It’s easy enough to get a list of spreadsheets for a user, or a list of folders, but there’s a trick to getting the contents of a folder. The first part of the trick is to ignore the category. Firstly, because it’s removed in version 3.0 of the API, and secondly because it filters by


Convert file path to file URL

A very short note: I was trying to find an analogue to Java’s File.toURI().toURL() method in .NET, looking through System.IO et al, and not finding it on the lazyweb. To my surprise, all you need use is UriBuilder: new UriBuilder(@”c:\path\to\file.txt”).ToString(); This will output “file://c:/path/to/file.txt“. Simple, but far too much time wasted finding it…


*Reset*

I originally started this blog as a way to push back some of the discoveries I had to the wider community in the hope that it would help prevent others making my (countless) mistakes. Who knows if the second try will work…