DNS Mapping With ASP.Net

Background

Developers (with this I mean entry level developers) are least bothered about deployment environments. I am not blaming all of them, but most of the people do not worry or even try to understand what is required to deploy an ASP.NET application (in fact any other technology app on an application server). For this article we will keep our focus on ASP.NET / IIS combinations.

Ever wondered why an IP address exists? Ever wondered why we need a domain name if an IP exists? All these answers are in this article.

What an IP Address is

As per the Wikipedia, an IP address is mainly used to identify a host/network interface (read this for more details). So with this, we can uniquely identify the server (or a host machine) that is hosting your application. It also is normally used to identify machines inside a VLAN.

It takes a form of numbers separated by a dot (.). For example, 127.0.0.1.

What is DNS

DNS stands for Domain Name Server. Now we know what an IP address looks like. Can you imagine remembering all your favorite websites by their IP addresses? I bet you can't. It is easier to remember CsharpCorner than to remember the IP address 74.81.194.29. So if machines need an IP address to identify a server and humans can't remember it well, how will this work out?

DNS comes to help us here. In a DNS, you map a domain name (for example C-sharpcorner.com) to the respective IP address. When you key in the website address, the browser does a DNS lookup for a matching IP address. If it is mapped, the browser then connects to that IP address and then the application server takes it from there. When Google Chrome does not find a website mapped to an IP address, it blames the DNS, see the following:

host

How to: DNS

You need to get your domain registered using some Domain name registrar. This entity ensures that the domain name is unique and is not owned by another entity. More details here. These registrars will make you pay a subscription fee for owning a domain. Once you have a domain, you can approach a hosting provider, who will provide you with an IP address. Hosting providers may provide you a “shared” IP address that it already uses for other clients as well. Or if you have enough funds, you can ask for a virtual server altogether. Independent servers will cost you more, however it will be faster than shared hosting most of the time. We won't get into the details of website performance here and will keep it for a separate article.

Now that you have an IP address and a domain name, how would you ensure that you get to serve the requests for your website? You will need to map the IP and domain in your application server. So the procedure will be:

  1. Publish your website in release mode. I hope you won't need a screenshot for that.
  2. Upload the published output to the hosting provider (generally shared hosting providers allow uploads via FTP).
  3. Now with shared hosting, it might already map the IP/domain for you, but we will assume that we own an individual server in this case. So you have your code on the server box, next you will create a website in IIS. Once you opt to create a website, you are asked the following questions:

add website

Site name: This will be used to identify your site. The application pool will also be named likewise.

Content Diretory: This is where you uploaded your code on the server. Note that the folder that you pick should contain the bin folder. So for example, if you have uploaded code to
"C:\inetpub\wwwroot\yourwebsite" and "yourwebsite" folder contains the bin, then you will need to choose "C:\inetpub\wwwroot\yourwebsite" as the physical location.

Binding: This is where we are supposed to choose (or rather map) the domain name we purchased. It will go under the host name. The IP address should automatically appear under the IP address drop down, since it will be done by your virtual server provider. The port will be 80 for HTTP and 443 for HTTPS.

Now you are ready to serve your application over the internet. There are other points to be taken care of, like authentication and so on. However I assume this is enough for a beginner to get their hands dirty on this.

Up Next
    Ebook Download
    View all
    Learn
    View all