Setting up local IIS with Umbraco CMS

What I like to do when I develop using Umbraco is to set up a local IIS server. Mainly because when I’m debugging or making changes I don’t want to rebuild and relaunch the server from Visual Studio all the time. There is also an easy way to make the set it up without having to edit the host file.

What you need

  • IIS Manager
  • Visual Studio (I’m using 2019)

Adding your website to IIS Manager

I’m going by the assumption that you already have IIS Manager installed and working, if you don’t I suggest looking up the Microsoft docs.
In the left tab select your desktop, right-click sites and select add website.
Which should prompt you with the view below.

IIS Add Website window.

Site name, give a name to your website, for this example, I will use Phantom.

The physical path should point to your Umbraco web project (.NET MVC), it’s important that it’s the project folder and not the fold holding the solution.

The hostname should be set to phantom.localtest.me, wheres localtest.me is a webserver that points back to localhost (127.0.0.1), meaning you can use this server without having to edit your host file.

Click Ok.

Before you can access your website you need to give permission to IUSR and IIS_IUSR to allow modify.


Navigate to your projects directory, right-click the web project and go to properties > security > edit > add > advanced > find now, scroll down the list until you find IUSR and IIS_IUSR hold ctrl and select both, click Ok.
In the permission window, select each new user and check the box to allow Modify.

Open any browser and type http://phantom.localtest.me, this should now launch your Homepage if you have no homepage set up yet it will launch the Umbraco setup page. You can also directly visit http://phantom.localtest.me/Umbraco to get to the back office of the CMS.

Back in Visual Studio, right-click your project > properties > web > scroll down to servers > in the dropdown, select local IIS > set project URL to http://phantom.localtest.me > save.

Debugging with local IIS

If you need to run the debug you can use attach to process. This allows you to use local IIS and still run the Visual Studio debugger.
In Visual Studio, place any breakpoints you wish then go to Debug > Attach to process (Ctrl + Alt + P) > Toggle “Show process from all users” > Look for username IIS APPOOL\Phantom > Select it and click Attach.
Navigate back to your http://phantom.localtest.me and hit refresh or do what you need to do to activate the breakpoint. You can now step through your code and debug as you are used to.

Note that you need to run Visual Studio as admin.

Conclusion

The advantage of setting up a local IIS server is that it allows you to always keep the website running, you don’t have to hit Ctrl + F5 to start the server from Visual Studio and then go back to check your changes etc.
It’s also easier to keep track of your custom URL to check your site, rather than the one created by IIS Express, which also keeps changing if you restart the server.

Leave a Comment

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