500 – Internal Server Error when accessing package manager in WebMatrix

Ran into this recently, so I wanted to share the resolution.

The scenario is that you’re working on an ASP.NET Web Pages project in WebMatrix, and you want to manage the Helper packages that are installed for your project. The way to do this is to visit https://<mysiteurl>/_Admin, which will prompt you for a password the first time you visit, then once you’ve got the password in place, will allow you to access the Package Manager, which consumes a NuGet feed of packages designed for use with ASP.NET Web Pages and WebMatrix (in the RTM version, you’ll have to modify a file in your project to verify that you, rather than someone else, set the password).

I ran into a situation where I had an existing project that I’d started on my desktop machine at home, then shared the source online so I could keep working on the project while I traveled to the 2011 MVP Summit. When I tried to visit the Package Manager on my laptop while working on the project, I kept getting a 500 – internal server error once I’d logged in.

Turned out that I had an older version of Microsoft WebMatrix (CTP2, I think) installed on my laptop. Because there weren’t very many significant UI changes between CTP2 and RTM, I didn’t pick up on this until I started digging deeper into where the error was coming from. Turns out that, not surprisingly, the default NuGet feed used by the Package Manager was updated between CTP2 and RTM. The old feed isn’t working anymore, and that was the error I was seeing.

So if you’re working with Microsoft WebMatrix and ASP.NET Web Pages, and run into a 500 error in the Package Manager, go grab the latest version of the Web Platform Installer, and make sure you’re running the RTM version of Microsoft WebMatrix. It’s free, after all, so there’s no reason not to.