In this article, I will tell you how to configure DNS record for sub domain.

Step 1

Open your domain control panel then go to DNS manager.

Step 2

Add following A records for and which point to IIS server IP address:  IN A XXX.XXX.XXX.XXX  IN A XXX.XXX.XXX.XXX IN A XXX.XXX.XXX.XXX

First two rows will ensure that whenever user browse or at that time it will be routed to IIS server and rest will be take care by IIS then it will serve public site. The third row in above is important for next step.

Step 3

Now add following wildcard CNAME record:


In above wildcard entry ensure that any sub domain request for will be routed to server which is pointed by

In IIS setup, you have to edit website binding to include and as host header, by this way you can tell IIS that any request from and will be handled by this particular website. So, whenever user browse or it is serving public website without any problem.

While in case of sub domain it is showing error that “The connection was reset” this is because IIS does not found host header entry for requested domain in any websites. So, you need to add host header entry in website created in IIS setup because is actual website which is going to serve hosted service application when it is browse from sub domain. Use the following code to add host header entry programmatically in IIS:

private string GetWebSiteId(string serverName, string websiteName)


    string result = "-1";


    DirectoryEntry w3svc = new DirectoryEntry(string.Format("IIS://{0}/w3svc", serverName));


    foreach (DirectoryEntry site in w3svc.Children)


        if (site.Properties["ServerComment"] != null)


            if (site.Properties["ServerComment"].Value != null)


                if (string.Compare(site.Properties["ServerComment"].Value.ToString(),

                                        websiteName, true) == 0)


                    result = site.Name;







    return result;



private void AddHostHeader(string hostHeader, string websiteID)


    DirectoryEntry site = new DirectoryEntry("IIS://localhost/w3svc/" + websiteID);

    PropertyValueCollection serverBindings = site.Properties["ServerBindings"];




    Object[] newList = new Object[serverBindings.Count];

    serverBindings.CopyTo(newList, 0);


    site.Properties["ServerBindings"].Value = newList;




AddHostHeader("", GetWebSiteId("localhost", "")); IIS 8.0 Hosting is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.