6

I'm getting a 400 bad request error message when accessing an ASP.net web api via a url that uses the computer name. When I use localhost it works fine. I'm using the iisExpress for visual studio 2012.

Any help is appreciated! Thanks in advance!

ptn77
  • 567
  • 3
  • 8
  • 23
  • did you try using the FQDN or the IP Address? – apollosoftware.org Jun 20 '13 at 20:52
  • 1
    are you using iis or iis express to host the application? – technicallyjosh Jun 20 '13 at 20:55
  • Hello, thank you for taking time to read and respond. I'm using iis express and computer name but not fully qualified. In my hosts file I have my computer name set to 127.0.0.1. I will try using the fully qualified name to see if it helps – ptn77 Jun 25 '13 at 20:09
  • I tried it with the fully qualified domain name added to my computer name and still get the same error. The reason why I need to use the computer name instead of localhost is that I want to trace it with fiddler. Fiddler will not work with localhost. When I use my computer name, I am able to get fiddler to log but then I get the error "HTTP Error 400. The request hostname is invalid." from the ASP.net web api. – ptn77 Jun 25 '13 at 20:26
  • How is the site in IIS Express configured? Does it expect a hostname when requests are sent to it? – JB King Jul 02 '13 at 15:46
  • I'm new to ASP.net Web api and not sure where I should look for the url configuration on the site. I'm using the ValueController that inherits from ApiController. Is there a way to specify the url in the web.config? – ptn77 Jul 09 '13 at 17:16
  • I found the answer to this from another post on here. I had to update my IISExpress' applicationhost.config file and add a binding with my computer name on it. The link to the other post is here: http://stackoverflow.com/questions/5433786/configure-iis-express-for-external-access-to-vs2010-project – ptn77 Jul 09 '13 at 20:21

2 Answers2

7

I found the answer to this from another post on here. I had to update my IISExpress' applicationhost.config file and add a binding with my computer name on it.

The link to the other post is here: Configure IIS Express for external access to VS2010 project

Community
  • 1
  • 1
ptn77
  • 567
  • 3
  • 8
  • 23
0

If you prefer not to change configurations, you can use our free VS extension called Conveyor

https://marketplace.visualstudio.com/items?itemName=vs-publisher-1448185.ConveyorbyKeyoti

Jim W
  • 4,866
  • 1
  • 27
  • 43