错误的请求 - 无效的主机名和Asp.net的WebAPI项目在Visual Studio 2013 [英] Bad Request - Invalid Hostname with Asp.net WebAPI project in Visual Studio 2013
问题描述
我在Visual Studio中运行的一个非常基本的WebAPI项目临2013年它运行在我的机器上本地主机的罚款。然后我试着去浏览器从不同的机器,并转到:57571类同我怎么可能指向通过将服务器ip地址后面的端口号Rails应用。然后我得到
错误的请求 - 无效的主机名 HTTP错误400请求主机名无效
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 2013年亲我运行相同的应用程序,它在本地工作正常。然后,如果我尝试点从另一个VM(在同一个虚拟的网络上,我还可以ping服务器VM)我仍然获得的错误的请求 - 无效的主机名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.
提醒你,我不约自定义DOMIAN我只是想能够运行使用该IP地址的另一台机器这个应用程序的照顾。这可能吗? (如果有的话是什么我做错了任何想法?)
下面是我尝试
<一href=\"http://stackoverflow.com/questions/14725455/connecting-to-visual-studio-debugging-iis-ex$p$pss-server-over-the-lan\">Didnt对我来说工作
<一href=\"http://stackoverflow.com/questions/4709014/using-custom-domains-with-iis-ex$p$pss/5186680#5186680\">This还剪掉使其工作
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
我怎么能告诉Visual Studio是运行作为管理员?
How can i tell visual studio is running as an admin?
(我使用Windows Server 2012 R2,其中视觉工作室正在运行。我关掉防火墙在两台机器上)
(I am using windows Server 2012 R2 where visual studio is running. I turned off the firewall on both machines)
推荐答案
下面是我如何得到它的工作。
Here is how I got it to work.
转到C:\\用户\\您的用户名\\文档\\ IISEx preSS \\设置\\对ApplicationHost.config中的的Visual Studio 2013
goto C:\users\yourusername\Documents\IISExpress\config\applicationhost.config in Visual Studio 2013
以下行加入对ApplicationHost.config 做它的工作。
Add the following line to applicationhost.config made it to work
<binding protocol="http" bindingInformation="*:53676:*" />
如果这没有工作
<binding protocol="http" bindingInformation="<clientsIPaddress>:53676:*" />
Vs2015更新和详细的位置此修改 application.config 概述如下。
该文件的路径是VS 2015以下
The path to the file is the following for VS 2015.
C:\\用户\\\\ {您的用户名} \\文档\\ Visual Studio的2015年\\项目\\\\ {} ThisSolutionName VS \\\\ \\ CONFIG \\对ApplicationHost.config。
丹尼尔提到的。
我在哪里把它放在我的application.config?
下面是部分家长在xml文件中,你会发现绑定。
Below are the parent sections in the xml file where you would find the bindings.
<system.applicationHost>
<sites>
<site name="WebSite1" id="1" serverAutoStart="true">
<bindings>
binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
</sites>
</system.applicationHost>
这就是大致行161 作为一个新项目,没有改变在对ApplicationHost.config什么。
This was roughly line 161 for a new project that didnt change anything in the applicationhost.config.
我没有意识到是我认为客户端的IP地址是,其实不是真实。是的原因是,我有一个互联星空在Azure中互联星空连接,并且在连接两个IP地址,网关重新分配在我的应用程序正在运行网络上的客户端的IP地址。因此,我不得不仰视它映射到新的IP地址,以便不使用的:端口:的策略
What I didnt realize is what I thought the clients IP address was, actually wasnt 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
这篇关于错误的请求 - 无效的主机名和Asp.net的WebAPI项目在Visual Studio 2013的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!