Site icon Ryadel

Visual Studio - How to rename a ASP.NET Web Site project

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.

 

Exit mobile version