Wednesday, July 1, 2015

Configure HostHeaders for SharePoint Web Application in Dev Boxes.

How bad it looks when developing our applications in our dev boxes we use url's like http://xyz-servername:port/

With 2013 to configure apps we need to have some DNS entries created. But traditionally not every developer care to have dns entries created for web applications in dev boxes.

Also learning from my past lessons with different urls in Dev and Production for the simmilar sites, sometimes you have to manually change the urls in infopath forms, workflows to republish the working stuff.

To make things better, here is the way i am sharing on how to configure host header and edit bindings to let the host header work for you without configuring anything on DNS.

We will use Powershell to modify the host file and will also set bindings on IIS to make WebApplication availlable outside the server.

Here are the steps:-

Create a WebApplication (You can extend one if you want to override the existing one).

I just have created a normal web application with host header "ankurmadaan" and port i used is 80. Note:- i allready have a sharepoint default web application on port 80.

Now we need a root site collection, I like to keep my site collections in there own database, for me it will be root collection so it will go into default database.

So now if you try to browse, you will be surprise to see that your site does not works, unless you have an entry for http://ankurmadaan in DNS mapped to ip of your server.

Also you will be loop back and Authentication Required pop up will keep coming.

So here is the solution, we will write Powershell Script to make this work:-

First we will write script to get path of hosts file and create a copy of it:-

Now, this will work when you are inside the servers, what will you do to have it accessed by users from outside of the server in your network, like you want to demo it someone, so here is the way to do it:-

Go to IIS and right click on this Web Application and click on Edit Bindings:-

Add a new entry and specify the port name and add server name(current server) on which you are configuring this, WFE if your dev box has multiple servers:-