Saturday, March 26, 2016

How to access IIS hosted site from another PC

I was working on a Intranet project for one of my client. Earlier It had to be developed with Apache web server. But later they wanted it to be developed with IIS (Internet Information Service) server. So we wanted the site i.e web application to be accessed by other PCs on the local network which's hosted on IIS Server.

To achieve this you need to follow the below steps:

1. First you should know the port on which your site can be accessed. For example it's 6060 in my case. You can get it through the web matrix or IIS manager. Looks as below in the web matrix:



First we need to open this port for the public access using the windows firewall.
      1. Open the Control Panel
      2. Open the Windows firewall
      3. Click on Advanced Settings
       

      4. Select Inbound rules.

         

      5.  Select New Rule:

            



       6. Select the Port

                 

     7. Select TCP and enter the port number. In my case it's 6060

               

         8.  Check Allow connections and click on Next button

            

        9. Select the profile as all the three, public, private and domain as shown below:

           

        10. Now save it with a Name. That's it for opening a port.

2.  Now we need to do some settings in the IIS. Go to IIS Express installation folder. Select config directory.


3. Now open the applicationhost.config file for edit.
4. Search for bindings and enter the below line as shown:

   <binding protocol="http" bindingInformation="*:6060:*" />
                </bindings>


5. Stop the Site through IIS or Webmatrix and save this file.
6. Now open the command prompt with the admin permission (Right click on command prompt and run as administrator)
7. Run the below command in he command prompt as shown:

                       netsh http add urlacl url=http://*:6060/ user=Everyone
You can change the port to match yours. Mine is 6060 hence I mentioned as 6060.


8. Now restart the IIS server and try to access the intranet application with the other PC with the below URL

http://<IP Address of he Server>:PORT 

That's it. Happy Coding.











No comments: