2020-02-19

Access ASP.NET website hosted in IIS Express from another machine on the local network (VS 2019)

I needed to test Mac Safari against a website I was developing on a Windows machine. Instead of being required to publish for every change, I wanted to just expose IIS Express across the LAN and hit the website that way. In order to do so, I had to do the following:

  1. Run Visual Studio 2019 as Administrator
  2. Edit {ProjectRoot}/.vs/{WebProjectName}/config/applicationhost.config
  3. In the <sites> section, add a binding under the website project's <site> definition (see below):
  4. Allow the desired port through your firewall
<site name="FocusAndExecute" id="1">
  <application path="/" applicationPool="Clr4IntegratedAppPool">
    <virtualDirectory path="/" physicalPath="{path_to_site}" />
  </application>
  <bindings>
    <binding protocol="http" bindingInformation="*:51427:localhost" />
    <binding protocol="http" bindingInformation="*:51428:192.168.1.123" />
  </bindings>
</site>


After doing this and launching IIS Express from Visual Studio, I was able to hit the site from the Mac by going to:
http://192.168.1.123:51428

NOTE: You may be able to put *:51428:* instead of specifying the IP, so you can hit it by host name, etc. but I didn't play with that yet.  Feel free to leave a comment if you have a better way!

No comments: