Admittedly, It took me some time to figure out how to properly configure an IIS Express Server on a locally hosted machine so that I could establish a connection to the server from a secondary computer. I have although finally gotten the gist of it, so I have put together a guide for others who wish to host their own IIS Express Server.
One of my major issues was that I didn’t run Visual Studio as an Administrator, so keep that in mind should you run into problems.
Additionally, if this guide doesn’t cut it for you, you may also try by directly specifying the name of your computer as described in this guide. When I tried, although, I experienced that I couldn’t properly establish a connection to the server when reserving an URL.
Hosting an ASP.NET Web Api on an IIS Express Server
1. First, we’ll need to create the virtual directoy:
1.1 Open Visual Studio as Administrator
1.2 Open and expand your project
1.3 Navigate to “Properties” -> “Web”
1.4 Ensure that the “Project Url” is “http://localhost:64485”
1.5 Click “Create virtual directory”
2. Now launch the site by:
2.1 Right-clicking on your ASP.NET Web Api project
2.2 From here, select “Set as StartUp Project”
2.3 Launch the site
3. Stop debugging & close Visual Studio
4. Now, in Windows:
4.1 Navigate to”C:\Users\Dave\Documents\IISExpress\config”
4.2 Open the “applicationhost.config” file”
4.3 Search for “bindings”
4.4 Find the entry which contains the name of your API
4.5 Add the highlighted line below the existing localhost binding
<bindings> <site name="Your.API" id="4"> <application path="/" applicationPool="Clr4IntegratedAppPool"> <virtualDirectory path="/" physicalPath="C:\Programming\Your.API" /> </application> <bindings> <binding protocol="http" bindingInformation="*:64485:localhost" /> <binding protocol="http" bindingInformation="*:64485:" /> </bindings> </site> <site> ... </site> ... </bindings>
5. Lastly, you’ll need to configure your firewall
5.1 In Windows, open “Control Panel”
5.2 Click “Windows Firewall”
5.3 Click “Advanced Settings”
5.4 Click “Inbound rules”
5.5 Select “Port”
5.6 Click “Next”
5.7 Select “TCP”
5.8 Enter port 64485
5.9 Click “Next” twice
5.10 Provide a name of your choosing
6. Finally, we’ll need to launch the site once more
6.1 Open Visual Studio as Administrator
6.2 Find your project
6.3 Launch the site
You should now be able to access the API using:
Do we need to use only port 64485 mentioned above, any other port should work?
took me 2 days to find this tutorial and its the first one that worked
Glad to know the guide helped you. If you found anything I could possibly change in the guide to improve it, please don’t hesitate to reach out to me.
Please don’t hesitate to leave any experiences you’ve had yourself hosting an IIS Express Server!
I will make sure useful observations are included in the post.