• Cloudlene Inc.

Expose IIS & ASP.Net Core Site/API to the World

Port forwarding
  1. Navigate to the router gateway (Ex. http://192.168.0.1). Gateway address can be found by running "ipconfig"

  2. Port forward the public IP to your local IP. https://www.whatismyip.com/ will provide your Public IP & Local IP

  3. Ensure your firewall doesn't block the ports (80 & 443 typically)

Install and/or Configure IIS
  1. Install IIS & IIS Management Service by using "Turn Windows Features on/off" on Windows 10.

  2. For Windows Server, Install Role & Features. Make sure to select the IIS Management Service. This is needed to Web Deploy from Visual Studio.

  3. Install the latest version of the .Net Core Runtime & Hosting Bundle

Update DNS Records
  1. Mine was GoDadday

  2. Add 2 A records: One with @ pointing your public IP AND www also doing the same. TTL can be 600 seconds.

  3. Remove all default records to cleanup except the name servers

  4. Leave the name servers as defaults

Prep IIS for the App - Create a new Website
  1. Add a New Web Siite in IIS

  2. Provie a Sitename (www_example_us)

  3. Create a blank directory & point to it in the Physical Path (c:/<appname>). IIS for weird reason throws exceptions if you set it to c:\<appname>.

  4. Host name should be your domain name

  5. Optionally, Uncheck start the website immediately as this may interfere with update process

  6. Hit Save

Prep IIS for the App - Link the domain with your site
  1. Right click & edit bindings

  2. Add another record with a host name matching the naked domain (i.e. example.us... see www missing)

  3. Optionally, you may also "Edit the bindings" for the "Default Web Site"

  4. Mapping it a to hostname that's having its A address point to the public IP address, disables the access of the website through the IP. In other words, the blank in the host name is necessary for IIS to map the IP to the default web site.

  • The user can still connect to IIS but will receive a 404, so "hiding" the default web site with a mapping, is not the right way to remove access through the IP address.

  • Adding another binding with a blank host name restores the use of IP address from the internet

Prep IIS for the App - Configure App Pool
  1. Navigate to the application pools node

  2. Reveal the pool that matches your site name (www_example_us)

  3. Right click to edit the basic settings

  4. Select 'No Managed Code' as Core apps do not use the desktop CLR

Publish app to IIS from Visual Studio
  1. Open Visual Studio

  2. Right click on the ASP.Net Web or Web API project

  3. Click Publish, Select IIS, FTP as the target & Click Publish on the popup

  4. Server should be the computer name you've installed IIS on

  5. Site name is the site name from IIS (Remember we chose "www_example_us")

  6. Leave username, password blank

  7. Destination URL should be the one that we mapped (http://www.example.us)

  8. Clicking validate connection should say OK

  9. You may get a popup for login credentials. Type in the local admin creds of the IIS box

  10. Hit 'Next'

Access the site from your browser
  1. Open your preferred browser

  2. Navigate to http://www.example.us or http://example.us or http://<yourpublicip>>

32 views0 comments

Recent Posts

See All

This article assumes that you are familiar – have heard of - with infrastructure as Code (IaC) technologies such as Terraform, Pulumi, ARM Templates for Azure, then you already understand where to use