"bad request (invalid hostname)" appears when deployed for virtual hosting

     

Bad Request - Invalid Hostname HTTPhường. Error 400. The request hostname is invalid.

Bạn đang xem: "bad request (invalid hostname)" appears when deployed for virtual hosting

I don"t even know where to begin to lớn diagnose this problem


*

*

Did you check the binding is IIS? (inetmgr.exe) It may not be registered khổng lồ accept all hostnames on 8080.

For example, if you mix it up for mysite.com:8080 and hit it at localhost:8080, IIS will get the request but not have a hostname binding to match so it rejects.

Outside of that, you should kiểm tra the IIS logs (C:inetpublogswmsvc#) on the VPS và see if you are seeing your request. Then you"ll know if its a problem on your client or on the server itself.


*

FWIW, if you"d lượt thích lớn just allow requests directed to any hostname/ip then you can phối your binding like so:

I use this binding so that I can load a VM with IE6 and then debug my application.

Xem thêm: Hơn 999+ Bài Thơ Chế Về Tình Yêu Và Cuộc Sống Hài Cười Vỡ Bụng

EDIT: While using IIS Express khổng lồ debug, the mặc định location for this option"s config tệp tin is

C:UsersUserDocumentsIISExpressconfigapplicationhost.config

*

*

This page by Microsoft describes how khổng lồ mix up access to IIS Server Express from other computers on the local network.

In a nutshell:

1) from a comm& prompt with admin privileges:

netsh http add urlacl url=http://:8181/ user=everyone2) In Windows Firewall with Advanced Security, create a new inbound rule for port 8181 lớn allow external connections

3) In applicationhost.config, in the node for your project, add:

Do NOT add (as was suggested in another answer):

The above sầu wildthẻ binding broke my access from http://192.168.1.6:8181/


Share
Improve this answer
Follow
edited Aquảng bá 24 "15 at 9:41
itzmebibin
8,40066 gold badges4444 silver badges5656 bronze badges
answered Oct 29 "14 at 22:44
ErwinErwin
49566 silver badges88 bronze badges
3
Add a bình luận |
25
So, I solved this by going to my website in IIS Manager & changing the host name in site bindings from localhost khổng lồ *. Started working immediately.

*


Share
Improve sầu this answer
Follow
answered Aug 10 "15 at 17:00
SINGULARITYSINGULARITY
90999 silver badges99 bronze badges
3
Add a comment |
10
For Visual Studio 2017 và Visual Studio 2015, IIS Express settings is stored in the hidden .vs directory and the path is something like this .vsconfigapplicationhost.config, add binding like below will work

Syntax:https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.administration.binding.bindinginformation?view=iis-dotnet


Share
Improve sầu this answer
Follow
edited Aug 24 "20 at 18:55
RJFalconer
8,82833 gold badges4646 silver badges5858 bronze badges
answered Oct 23 "17 at 9:39
imgenimgene
2,40766 gold badges3636 silver badges5959 bronze badges
2
Add a phản hồi |
5
Don"t forget to bind to the IPv6 address as well! I was trying to lớn add a site on 127.0.0.1 using localhost và got the bad request/invalid hostname error. When I pinged localhost it resolved to lớn ::1 since IPv6 was enabled so I just had khổng lồ add the additional binding lớn fix the issue.

*


Share
Improve sầu this answer
Follow
answered Oct 30 "15 at 21:45
Jeff CameraJeff Camera
5,04644 gold badges4040 silver badges5858 bronze badges
1
Add a bình luận |
4
This solved my problem (sorry for my bad English):

open cmd as administrator and run command (Without the square brackets):netsh http add urlacl url=http://:/ user=everyone

in documents/iisexpress/config/applicationhost.config và in your root project folder in (hidden) folder: .vs/config/applicationhost.config you need add row to "site" tag:

open "internet information services (iis) manager"(khổng lồ find it: in search in taskbar write "Turn Window features on or off" and open result và then kiểm tra the checkbox "internet information service" and install that):

in left screen click: computer-name --> Sites --> Default Web Site andthen cliông chồng in right screen "Binding"clichồng Add buttonwrite what you need and press "OK".

open "Windows Firewall With Advanced Security",

in left screen press "Inbound Rules" & thenpress in right screen "New Rule..."check port and press Next,check TCPhường. & your port & press Next,check "Allow the connection" and press Next,check all checkbox & press Next,write name và press Finish.

Xem thêm: Bán Buôn Iphone Tại Hà Nội Và Miền Bắc,=>Giá Tốt Cuối Tuần!!!

done.


Chuyên mục: Công nghệ