3

I created a simple Asp.net Web Api. When I run the code Chrome is opening and getting xml data from sql server database. Here is the link: http://localhost:50599/api/Menu/. And this my output: https://i.sstatic.net/hKeZd.png

But when I put my local address instead of "localhost" it gives me 400 error. My IIs is running. when I enter 127.0.0.1 or 192.168.1.104 or localhost IIS page is opening.

I did everything for opening 127.0.0.1:50599/api/menu or 192.168.1.104:50599/api/menu but error 400 apears. I changed

<binding protocol="http" bindingInformation="*:8080:localhost" /> 

to

<binding protocol="http" bindingInformation="*:8080:*" />

and it didnt work for me.

How can I solve this problem. If I can make this work I will access this Api from an android device.

7
  • Quick check: your "working" config is using port 50599 (not 8080). Commented Nov 25, 2017 at 18:38
  • But in applicationHost.config file Port is 8080. I changed 8080 to 505999 but it didnt work. Commented Nov 25, 2017 at 18:45
  • what do you mean by local address - your computer name? try a ping on your local address, and see if any ip address is resolved. Commented Nov 25, 2017 at 19:25
  • my ip adress is 192.168.1.104 Commented Nov 25, 2017 at 19:40
  • @NicatGüliyev 192.168.x.x cannot go over the Internet. It is a local address for local hosts. Local means a close neighbour. You should search Google for "400 error". Commented Nov 25, 2017 at 21:58

1 Answer 1

11

I ran into the same problem you did and I know I'll be repeating some of the stuff you did but try to bear with me.

Edit the applicationhost.config in the root solution folder. It's in a hidden folder called .vs.

In your site, add:

<binding protocol="http" bindingInformation="*:port:*" />
<binding protocol="http" bindingInformation="*:port:youripaddress" />

If you see 8080 which is the default port, you are in the wrong section.

Open Visual Studio in administrator mode.

Sign up to request clarification or add additional context in comments.

1 Comment

Great to find out this answer. Also, the 'Open VS in Administrator' is important. Took me few minutes to find out I overlook the last sentence.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.