nmrlqa4
nmrlqa4

Reputation: 679

How to access an ASP.NET web api that runs on localhost (IIS)

I built an ASP.NET Web API. I run it locally from Visual Studio on IIS Express. I need to access this api from other device from another network, so I understand that it has to be hosted on the development machine on IIS, right? What I read is that:

  1. I need to enable IIS Manager in the Control Panel (source) - DONE
  2. Assign the IP of the dev machine to the localhost (source; source 2) - I don't see my site in the IIS Manager under Sites, only see Default Web Site. Why is that?
  3. I assume the site needs to be hosted somehow on the dev machine, because I need to stop Visual Studio, therefore the IIS Express will be stopped and the site would not be accessible, even from localhost right?

My dev machine has a public static IP and I can access this Default Web Site successfully from outside.

Upvotes: 2

Views: 8318

Answers (1)

Fanosss test
Fanosss test

Reputation: 36

You should consider your API in IIS just as any IIS App. i.e. a website. It needs to have an IP (or a hostheader value) Lets say api1.example.com binded in IIS with your IIS Application. Your DNS must resolve this to the IIS machine IP. then you can access it in that URL.

You can also just hit the machine IP running the IIS web server (on the port you added for the api - if its not :80) See "Bindings" in IIS

See this Video : https://www.youtube.com/watch?v=I32AnqJzD58

Upvotes: 2

Related Questions