1. Original Entry + Comments2. Write a Comment3. Preview Comment
New comments for this entry are disabled.

June 04, 2011  |  Moving a website in WebMatrix  |  32984 hit(s)

I created a website in WebMatrix and decided later to move it to a different location. Since the site's files are all self-contained, I just moved them in Windows Explorer. However, when I opened up WebMatrix, I went to My Sites and clicked on the site:

However, this resulted in an error:

Of course. So the question is how to get WebMatrix to understand the site's new location. Turns out to be pretty easy. The site information is in the applicationhost.config file which is in turn in (here's the not-intuitive part) the My Documents\IISExpress\config folder.
This is an XML file that has a element containing a child element for each site that WebMatrix knows about. All I had to do was change the highlighted bit to point to the new location:

<site name="MotorcycleBlog" id="11">
  <application path="/">
    <virtualDirectory path="/" physicalPath="C:\MotorcycleBlog" />
    <binding protocol="http" bindingInformation="*:6867:localhost" />

And thereafter WebMatrix opened the moved site from the correct location.

Alan Humphrey   04 Jun 11 - 6:48 PM

Thanks for this. I ran into this problem a few months ago but wasn't savvy enough to track down the solution.

soupman55   10 Jul 11 - 9:46 AM

I move the folder. (Don't move just a file, move the folder it is in.) Then I right-click the folder. And "low and behold" there is an option to open it with WebMatrix.

mike   10 Jul 11 - 12:10 PM

@soupman55, true that works to open the site. However, I think what you'll find is that WebMatrix will have created another entry in the XML file for the new location. If you created a database in the old location (e.g. oldlocation.sdf), it's possible it won't be found in the new location, because WebMatrix will be looking for newlocation.sdf.