I am running a very basic webAPI project in Visual Studio Pro 2013. It runs fine on localhost on my machine. I then try and go to a browser from a different machine and goto :57571 similiar to how i could point to rails apps by putting the servers ipaddress followed by the port number. I then get Bad Request - Invalid Hostname HTTP Error 400. The request hostname is invalid.
我在Visual Studio Pro 2013中运行一个非常基本的webAPI项目。它在我的机器上的localhost上运行正常。然后我尝试从另一台机器转到浏览器并转到:57571类似于我如何通过将服务器ipaddress后跟端口号指向rails应用程序。然后我得到错误请求 - 无效主机名HTTP错误400.请求主机名无效。
I also replicated this by putting two windows machines in azure. One running visual studio pro 2013. I run the same application and it works fine locally. Then if i try and point at it from another VM (on the same virtual network, i can also ping the server vm) I still get Bad Request - Invalid Hostname HTTP Error 400. The request hostname is invalid.
我也通过在天蓝色中放置两台Windows机器来复制这一点。一个正在运行的visual studio pro 2013.我运行相同的应用程序,它在本地工作正常。然后,如果我尝试从另一个VM指向它(在同一个虚拟网络上,我也可以ping服务器vm)我仍然得到错误请求 - 无效主机名HTTP错误400.请求主机名无效。
Mind you I dont care about a custom domian I just want to be able to run this app from another machine using the IP address. Is this possible? (if so any ideas on what i am doing wrong?) Here is what i tried Didnt work for me This also didnt make it work
请注意,我不关心自定义domian我只是希望能够使用IP地址从另一台机器运行此应用程序。这可能吗? (如果有的话我对错误做了什么想法?)这是我尝试过的不是为我工作这也没有使它工作
How can i tell visual studio is running as an admin?
我怎么能告诉visual studio作为管理员运行?
(I am using windows Server 2012 R2 where visual studio is running. I turned off the firewall on both machines)
(我正在使用Visual Studio运行的Windows Server 2012 R2。我关闭了两台机器上的防火墙)
2 个解决方案
#1
24
Here is how I got it to work.
以下是我如何使用它。
goto C:\users\yourusername\Documents\IISExpress\config\applicationhost.config in Visual Studio 2013
在Visual Studio 2013中转到C:\ users \ yourusername \ Documents \ IISExpress \ config \ applicationhost.config
Add the following line to applicationhost.config made it to work
将以下行添加到applicationhost.config使其工作
<binding protocol="http" bindingInformation="*:53676:*" />
where this didn't work
这不起作用
<binding protocol="http" bindingInformation="<clientsIPaddress>:53676:*" />
Vs2015 Update and the exact location for this change the application.config are outlined below.
Vs2015更新以及此更改的确切位置application.config概述如下。
The path to the file is the following for VS 2015.
VS 2015的文件路径如下。
C:\Users\\{YourUsername}\Documents\Visual Studio 2015\Projects\\{ThisSolutionName}\\.vs\config\applicationhost.config
as Daniel mentioned.
但是Daniel提到的C:\ Users \\ {YourUsername} \ Documents \ Visual Studio 2015 \ Projects \\ {ThisSolutionName} \\。vs \ config \ applicationhost.config。
Where do I put this in my application.config?
我在哪里把它放在我的application.config中?
Below are the parent sections in the XML file where you would find the bindings.
下面是XML文件中的父节,您可以在其中找到绑定。
<system.applicationHost>
<sites>
<site name="WebSite1" id="1" serverAutoStart="true">
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
</sites>
</system.applicationHost>
This was roughly line 161 for a new project that didn't change anything in the applicationhost.config.
对于一个没有在applicationhost.config中进行任何更改的新项目,这大致是161行。
What I didn't realise is what I thought the clients IP address was, actually wasn't true. The reason being is that I had a VNet to VNet connection in Azure and the gateway that is connecting the two IP addresses reassigns the clients IP address on the network in which my application was running. I thus had to look up the new IP address it was mapped to in order to not use the *:port:*
strategy
我没想到的是我认为客户端的IP地址,实际上并非如此。原因是我在Azure中有一个VNet到VNet连接,并且连接两个IP地址的网关重新分配运行我的应用程序的网络上的客户端IP地址。因此,我不得不查找它映射到的新IP地址,以便不使用*:port:*策略
#2
14
I can not comment, but wanted to answer @EthanKeiser
我无法评论,但想回答@EthanKeiser
Visual Studio 2015 has a separate config file for each Solution that you will need to update per the accepted answer. This file is located at:
Visual Studio 2015为每个解决方案都有一个单独的配置文件,您需要根据接受的答案进行更新。该文件位于:
C:\Users\\{UserName}\Documents\Visual Studio 2015\Projects\\{SolutionName}\\.vs\config\applicationhost.config
#1
24
Here is how I got it to work.
以下是我如何使用它。
goto C:\users\yourusername\Documents\IISExpress\config\applicationhost.config in Visual Studio 2013
在Visual Studio 2013中转到C:\ users \ yourusername \ Documents \ IISExpress \ config \ applicationhost.config
Add the following line to applicationhost.config made it to work
将以下行添加到applicationhost.config使其工作
<binding protocol="http" bindingInformation="*:53676:*" />
where this didn't work
这不起作用
<binding protocol="http" bindingInformation="<clientsIPaddress>:53676:*" />
Vs2015 Update and the exact location for this change the application.config are outlined below.
Vs2015更新以及此更改的确切位置application.config概述如下。
The path to the file is the following for VS 2015.
VS 2015的文件路径如下。
C:\Users\\{YourUsername}\Documents\Visual Studio 2015\Projects\\{ThisSolutionName}\\.vs\config\applicationhost.config
as Daniel mentioned.
但是Daniel提到的C:\ Users \\ {YourUsername} \ Documents \ Visual Studio 2015 \ Projects \\ {ThisSolutionName} \\。vs \ config \ applicationhost.config。
Where do I put this in my application.config?
我在哪里把它放在我的application.config中?
Below are the parent sections in the XML file where you would find the bindings.
下面是XML文件中的父节,您可以在其中找到绑定。
<system.applicationHost>
<sites>
<site name="WebSite1" id="1" serverAutoStart="true">
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
</sites>
</system.applicationHost>
This was roughly line 161 for a new project that didn't change anything in the applicationhost.config.
对于一个没有在applicationhost.config中进行任何更改的新项目,这大致是161行。
What I didn't realise is what I thought the clients IP address was, actually wasn't true. The reason being is that I had a VNet to VNet connection in Azure and the gateway that is connecting the two IP addresses reassigns the clients IP address on the network in which my application was running. I thus had to look up the new IP address it was mapped to in order to not use the *:port:*
strategy
我没想到的是我认为客户端的IP地址,实际上并非如此。原因是我在Azure中有一个VNet到VNet连接,并且连接两个IP地址的网关重新分配运行我的应用程序的网络上的客户端IP地址。因此,我不得不查找它映射到的新IP地址,以便不使用*:port:*策略
#2
14
I can not comment, but wanted to answer @EthanKeiser
我无法评论,但想回答@EthanKeiser
Visual Studio 2015 has a separate config file for each Solution that you will need to update per the accepted answer. This file is located at:
Visual Studio 2015为每个解决方案都有一个单独的配置文件,您需要根据接受的答案进行更新。该文件位于:
C:\Users\\{UserName}\Documents\Visual Studio 2015\Projects\\{SolutionName}\\.vs\config\applicationhost.config