How To Access Website Hosted In IIS From Any PC On LAN

Introduction

In this tutorial, I am going to explain various steps to access a website hosted in IIS from any PC on LAN. This detailed article will cover the following topics as follows,

  1. Introduction
  2. Terminologies
  3. Prerequisites
  4. Hosting a Website in IIS
  5. Create a Firewall Rule
  6. Points to Remember
  7. Conclusion

Terminologies

As per Wikipedia, "Internet Information Services (IIS, formerly Internet Information Server) is an extensible web server software created by Microsoft for use with the Windows NT family. IIS supports HTTP, HTTP/2, HTTPS, FTP, FTPS, SMTP and NNTP".

"Windows Defender Firewall with Advanced Security" Tool is used to create authenticate communication between systems (PCs). It is also used to view and create firewall rules. It is an important part of a layered security model. As per Microsoft, "It helps secure the device by allowing you to create rules that determine which network traffic is permitted to enter the device from the network and which network traffic the device is allowed to send to the network. Windows Defender Firewall also supports Internet Protocol security (IPsec), which you can use to require authentication from any device that is attempting to communicate with your device".

Prerequisites

  • Windows PC with IIS (Internet Information Services) installed.
  • Basic knowledge of website hosting In IIS (Internet Information Services).
  • Running Project (Here, I am using an ASP.NET web application).

Hosting a Website In IIS

Step 1

Click Start and type "IIS". Then click "Internet Information Services (IIS) Manager" to open the "Internet Information Services (IIS) Manager".

Access Website Hosted In IIS On LAN

(Alternatively, you can press "Windows + R" to open RUN and type "inetmgr" to open the "Internet Information Services (IIS) Manager").

Step 2

First, we create a new application pool to host our new web application. Follow steps 2a and 2b very carefully to create a new application pool.

Step 2a

Right-click on the "Application Pools", and click on "Add Application Pool...".

Access Website Hosted In IIS On LAN

Step 2b

Now, create a new application pool by choosing the following configurations. (Note, if you are using the latest version of the .NET framework, select the following options).

  • Give a name to your new application pool.
  • Select ".NET CLR Version v4.0.30319" option from .NET CLR Version.
  • Select the "Integrated" option from Managed pipeline mode.

Access Website Hosted In IIS On LAN

Step 3

Right-click on the Sites and select the "Add Website..." option from the list.

Access Website Hosted In IIS On LAN

Step 4

Now, enter the details as per the given fields and your requirements. And, click the "OK" button.

  • Site Name: Choose a name for your new website.
  • Application pool: Select the "Application pool" that you have created earlier, by clicking on the "Select" option.
  • Physical path: Select the main (root) directory of the application.
  • Binding
    1. Port: Select the required port, the default is 80. But, I am going to use port 9300.
    2. Host name: Do not enter a host name if you are testing or using it over a LAN.

Access Website Hosted In IIS On LAN

Note
If you do not select the Application Pool, a new application pool is created using the name of the site when the site is added. IIS defaults to one application pool per site.

Congratulations, you have successfully hosted your website in IIS.

Access Website Hosted In IIS On LAN

Locate your IP Address

Using the Command Prompt (Admin), the user can easily find the IP Address. Follow the instructions below to proceed.

Step 1

Open Command Prompt (Run as Administrator).

Step 2

Type "ipconfig" and press enter key. Here, the "IPv4 Address" is the IP address of your PC on the LAN.

Access Website Hosted In IIS On LAN

Now, you can replace the localhost with the IP Address in your website URL. (Like, use "http://192.16x.xx.xx:9300/login.aspx" in place of "http://localhost/login.aspx").

Access Website Hosted In IIS On LAN

Create a Firewall Rule

Now, you need to create a firewall rule to determine which network traffic is allowed to enter the device from the network.

Method 1: Using Command Prompt (Administrator)

A user can easily create Firewall Inbound Rules by using the Command Prompt (Administrator).

Step 1

Open Command Prompt (Run as Administrator).

Step 2

Type "netsh advfirewall firewall add rule name="Hosting Local Website On LAN" dir=in action=allow protocol=TCP localport=9300" and press enter key.

Access Website Hosted In IIS On LAN

Method 2: Using Windows Defender Firewall with Advanced Security

Follow the instructions below to create a new firewall inbound rule.

Step 1

Open Start, Search for "Windows Defender Firewall with Advanced Security", and press enter to open it.

Access Website Hosted In IIS On LAN

Step 2

Now, click on the "New Rule..." under Inbound Rules.

Access Website Hosted In IIS On LAN

Step 3

The "New Inbound Rule Wizard" window will appear on the screen. Now, set the Rule Type to Port. And, click "Next" to proceed.

Access Website Hosted In IIS On LAN

Step 4

Now, enter your port number in the "specific local ports". And, click "Next" to proceed.

  • As such, I am going to specify my 9300 port for my inbound rule.

Access Website Hosted In IIS On LAN

Step 5

Here, you have to specify the action to be taken when a connection matches the conditions specified in the rule. Click "Next" to proceed further by residing the default value (Allow the connection) ​​as it is.

Access Website Hosted In IIS On LAN

Step 6

Now, specify the profiles for which the rule applies. Again, click "Next" to proceed by residing the default values ​​as they are.

Access Website Hosted In IIS On LAN

Step 7

Here, specify the name and description of your Firewall rule. And, click on the "Finish" button.

Access Website Hosted In IIS On LAN

Congrats, your new inbound rule has successfully been created for your hosting of the local website on LAN. And, You will be able to access the website by providing http://<IPAddress>:<port> from any system on the LAN.
Now, if you share your hosted URL (like http://192.16x.xx.xx:9300/login.aspx) with someone else on your LAN, the website will open on his PC.

Points to Remember

  • Be careful while changing firewall settings otherwise you may make your PC vulnerable to online attacks.
  • Only use ports in the nonstandard/unofficial range (preferably after 9000).
  • You can remove the firewall rule after you finish using the website.
  • If you don't like your website URL calls using an IP address, you can use Domain Name Service [DNS]. To do this, simply find a DNS provider and register an account, so you can link your website with a name, not a series of numbers.

See you in the next article, until then take care and be happy learning.

You may also visit my other articles,

You can connect with me @

Conclusion

In this article, we have discussed various steps to access a website hosted in IIS from any PC on LAN.

I hope you enjoyed this article. Follow C# Corner to learn more new and amazing things.

Thanks for reading.


Similar Articles