Unbreakable
Unbreakable

Reputation: 8084

How to point the website to a particular Folder in IIS

I am a beginner in web development. I am not sure how to tell the website to point to a particular folder in IIS. I have ASP.Net MVC - 5 Web Application.

Step 1. Bought a domain/url.

Step 2. Bought a server with IP Address (Windows Server).

Step 3. Pointed the url to the Server's IP Address..

Step 4. Have locally published my webapp code from visual studio. And now I need to paste this code on the server.

Question 1. Now where do I need to put the code in server so that the IIS will host it and anyone visiting that website will hit that folder which has all my website code. I am a beginner please guide me.

Question 2. In future I will put another web site code too on that same server, let's say the URL for new web app is xyz.com. How to tell xyz.com to go to the other folder dedicated for it, and not the older one. Basically, How multiple web site hosting will work?

PS: using remote desktop client. I am able to log in to my windows server.

Upvotes: 4

Views: 23716

Answers (2)

Kaushal Kumar Panday
Kaushal Kumar Panday

Reputation: 2467

In IIS, by default one site is created which points to "%SystemDrive%\inetpub\wwwroot" and it has a default HTTP binding where it listens to all incoming requests on PORT 80.

Now in your scenario, you have several options. You can either create a new site and point it to the folder where your published code resides or you can edit the existing site configuration to point to the folder where your app resides. Below instruction is to edit the exiting site configuration:

  • Launch IIS Manager
  • Right click the Default Web Site and navigate to Manage Website > Advanced Settings
  • Under Default settings, update the physical path to point to the folder where the app resides.enter image description here

NOTE: you will have to give permissions to IIS_IUSRS account on the folder or run the application pool under the context of a user which has necessary privileges to read from the directory.

FYI, all the IIS configuration resides in applicationhost.config file which resides in C:\Windows\System32\inetsrv folder.

Inside this file, the site configuration is present under the <sites> xml tag. Here is an exmaple:

<sites>
    <site name="Default Web Site" id="1">
        <application path="/">
            <virtualDirectory path="/" physicalPath="%SystemDrive%\inetpub\wwwroot" />
        </application>
        <bindings>
            <binding protocol="http" bindingInformation="*:80:" />
        </bindings>
    </site>
</sites>

I wouldn't recommend editing the file directly as it can be prone to human errors. I would recommend to use appcmd commandline utility instead.

You can leave the binding as it is. As per the above binding, all the requests that hits port 80 on the server will be handled by the web app. If you intend to add HTTPS support, then you will have to purchase a SSL certificate and then add a SSL Binding for your site.

Upvotes: 7

justiceorjustus
justiceorjustus

Reputation: 1965

The website usually goes in the C:\inetpub\wwwroot folder. That is the default IIS root directory. You can change this if you please in the IIS settings mentioned below.

For the second website, you can add another folder anywhere on the server, technically. In IIS: Right-click Sites -> Add Web Site and then set the physical path and other details to your new site's file directory.

Edit: I missed the DNS part. You just have to point the DNS name through your hosting company to the IP and port of your website. For the second site, just put it through a different port and point to the same IP and that port. There's other ways to do it, however: Multiple domains on same webserver

Upvotes: 0

Related Questions