2

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.

nmrlqa4
  • 659
  • 1
  • 9
  • 32
  • You won't be able to access your API from another network unless you have a static IP, do you have it? – Riaz Raza Oct 25 '18 at 13:55
  • 1
    You almost there, you need to compile your asp.net web api by doing right click and then "publish" then when it compiles it will generate a folder with multiple aspx, dlls, etc.. You need to copy that folder into C:\inetpub\wwroot\ – Brank Victoria Oct 25 '18 at 13:57
  • @BrankVictoria, I did that with the publish to folder and then pasted it in the c:\inetpub\wwroot but the localhost still finds the old IIS template webpage. Weird – nmrlqa4 Oct 25 '18 at 14:11

1 Answers1

2

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