Visual Studio - How to rename a ASP.NET Web Site project Quick guide explaining how to rename an existing ASP.NET Web Site in Visual Studio 2013, 2015, 2017 and 2019

Visual Studio 2013 e 2015: Unable to start debugging on the web server. Could not start ASP.NET debugging - Come risolvere

If you stumbled upon this post it most likely mean that you're having some issues trying to rename a ASP.NET Web Site within a Visual Studio solution. As you might already know, ASP.NET Web Sites don't have the "rename" option when you right-click on them like ASP.NET Web Applications and almost any other project template: as a matter of fact, they cannot be renamed using the GUI - if you want to change their name, you have to manually edit something outside Visual Studio.

IMPORTANT: It's worth noting that we're talking about ASP.NET Web Sites here, not ASP.NET Web Application projects: if you want to understand the differences between these two project templates, we strongly suggest to read this post.

That "something" changes depending on which version of Visual Studio you're using.

Visual Studio 2013 (and below)

In order to rename the web site you need to open the IIS Express configuration file and change the <site> section of your Web Site project:

  • Locate the applicationHost.config file of your IIS Express: it should be in the  C:\Users\{username}\Documents\IISExpress\config folder.
  • Locate the corresponding <site> section of your project within that file.
  • Rename the old website name, putting the new name instead. If you prefer, you can also delete that <site> section entirely, as it will be re-created on first use.
  • Close and Reopen your solution in Visual Studio.

As soon as you do that, you'll found that the spefic name for your web project come back!

Visual Studio 2015 (and above)

The workaround for Visual Studio 2015, 2017, 2019 and (most likely) above is basically the same of VS2013, with a small difference: the IIS Express configuration path has been changed, they moved it away from the Windows user folder (smart move) and put it into a dedicated .vs\ folder within the main Solution folder.

The new path should be something like that:

  • {Solution}\.vs\config\applicationhost.config

Have it open, locate the old name and replace it (or delete the <site> section), then restart Visual Studio and you'll be good to go.

Conclusion

That's it for now: I hope that this post will be useful enough for those web developers who need to rename their ASP.NET Web Sites.

 

About Ryan

IT Project Manager, Web Interface Architect and Lead Developer for many high-traffic web sites & services hosted in Italy and Europe. Since 2010 it's also a lead designer for many App and games for Android, iOS and Windows Phone mobile devices for a number of italian companies. Microsoft MVP for Development Technologies since 2018.

View all posts by Ryan

One Comment on “Visual Studio - How to rename a ASP.NET Web Site project Quick guide explaining how to rename an existing ASP.NET Web Site in Visual Studio 2013, 2015, 2017 and 2019

  1. I followed your steps (I’m using VS 2017), and I failed in my first attempt!

    I found it that if the localhost address is not right in the Site config you want to keep, VS won’t accept the change.

    For example, I had a previous value that I wanted to keep, but it had an old localhost address. And the value I wanted to delete had the current one.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

This site uses Akismet to reduce spam. Learn how your comment data is processed.