WebMatrix Personal Site Links Throw 404 Errors

Today I was providing some assistance with WebMatrix 2 Release Candidate and found it intriguing.  Based on what I saw, I decided to take the plunge and start exploring WebMatrix to develop my personal site.

Sounds easy, right?  Especially since I don’t keep a lot of content on my personal site and primarily use it for testing.  I created a new site from the template gallery and selected personal site.  It is very basic, providing an easy interface to add feeds from my personal blog, twitter, and photo sites.

I followed the best practices and did all the testing and debugging locally using IIS Express and got everything working just the way I wanted for the initial upload of my site.  I was excited!  It was a simple process and took a very short period of time to have this basic site created and uploaded to my live web server.

After setting a new default document to default.cshtml, the home page was loading.  Wow, that was easy.  Then I clicked on my blog link to load my blog feed… and I got a 404 error – file not found.  I tested it locally again and it worked.  Back on the live site, it continued to throw a 404 for all the links.

It’s funny how we often like to read the documentation after we run into issues, which was the case this time.  The documentation provided little information other than letting me know that the links that weren’t working invoked ContentPage.cshtml to load the feeds.  Next it was time to turn to an Internet search for the answer.  After spending a good amount of time trying to find the right keywords to get an answer I finally stumbled upon a clue that led me in the right direction.

I realized that the WebMatrix personal site was using Extensionless URLs and by default IIS isn’t configured to handle this.  Since my site is running on IIS 7, the easy solution was to add one line to my web.config:

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
</system.webServer>

After making that change and publishing the updated web.config file, my site started working properly both locally and on the live, remote web server.

Rick is a Senior Support Lead at OrcsWeb, a hosted server company providing managed hosting solutions.