Bad Request - Invalid Hostname with Asp.net WebAPI project in Visual Studio 2013

后端 未结 4 508
甜味超标
甜味超标 2020-12-25 14:11

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

4条回答
  •  时光说笑
    2020-12-25 14:39

    Here is how I got it to work.

    goto C:\users\yourusername\Documents\IISExpress\config\applicationhost.config in Visual Studio 2013

    Add the following line to applicationhost.config made it to work

    
    

    where this didn't work

    
    

    Vs2015 Update and the exact location for this change the application.config are outlined below.

    The path to the file is the following for VS 2015.

    C:\Users\\{YourUsername}\Documents\Visual Studio 2015\Projects\\{ThisSolutionName}\\.vs\config\applicationhost.config as Daniel mentioned.

    Where do I put this in my application.config?

    Below are the parent sections in the XML file where you would find the bindings.

     
               
                  
                     
                          
                   
               
          
     
    

    This was roughly line 161 for a new project that didn't change anything in the applicationhost.config.

    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

提交回复
热议问题