How to fix HTTP 400 - Bad Request (Invalid Hostname) Error ?
If you are dealing with IIS(Internet Information Services) frequently then you can face HTTP 400 - Bad Request (Invalid Hostname) Error, i have faced the same error while trying to deploy the web application in my IIS 5.1 (Windows Server 2003) Machine. And i have surf a lot on the web to find the solution but all the stuff i found from the Googling was just messy crap.
After playing with IIS settings and changing some configuration, finally i have found the solution for HTTP 400 - Bad Request (Invalid Hostname) Error. Actually In my IIS i don't know why but 'Default Web Site' virtual directory was not there, and after completion of setup for my web application it was crashed instead of starting smoothly.
- When you get a message like this Turn off friendly HTTP error messages in IE.
1. To do this go to Tools >> Internet Options >> Advanced.
2. Uncheck show friendly HTTP error messages.
3. Once you have done this you should get a more detailed message which will point you to the real problem.
Steps to Solve HTTP 400 - Bad Request (Invalid Hostname) Error
Bad Request: Your browser sent a request that this server could not understand.
Step 1. First open your inetmgr (internet manager) and look for the "Default Web Site", if it's not there you can create it (Using virtual directory path as c:\Inetpub\wwwroot). It will help you to deploy your application under that.
Note: By default the Web applications installing under the "Default Web Site" are using PORT 80.It means you can access your web application by just typing the virtual directory name(Ex: http://localhost/Vir_Dir). But if you are installing your application under separate website then you must have to use another port in order to run it, because "Default Web Site" sites are using Port 80 by default (So in case of separate website you need to access it like: http://localhost/Vir_Dir:81 or any other port number)
- So now we are clear that we can run a single website on Port 80 at a time. If you will try to start two websites on a single port, it will throw a below given error.
Step 2. Right click on the virtual directory and select Properties.
Step 3. Now in Web Site Tab make IP address value as (All Unassigned)
Step 4. Click on Advanced... button given near the IP Address field (Refer above screen shot) and then on Advanced Web Site Identification Window select default IP address and click on Edit... button.
- Now Here is the key thing, you need do is Blank the Host Header Value.Means there should not be any value in host header value text box.
- Now just click Ok button and click Apply and Ok, and try to browse the application now..... :)
SHAIKH KABIR
Very Very Very much Thank you i saw many websited tried to solve this error but your solution solved it.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteI really appreciate your solution and you save my lot of time to fix this issue with your very straight forward and valuable solution.
ReplyDeleteThank you very much buddy..:)