How to access Web API posted to IIS externally

Asked

Viewed 2,426 times

1

I developed an ASP . NET Web Application (API) in Visual Studio 2015 and published it on IIS 6.1 to access locally. Now I need to make my machine available as a server for external access. How to do this?

2 answers

3

A complete answer depends on how your environment is structured, and is not trivial. I will list the requirements in a superficial way; you need to solve the details.

I’m taking over:

  • A typical residential connection (non-permanent IP address);
  • A non-commercial router like this;
  • A computer with IIS serving its Webapi.

The necessary steps would be:

  • Configure your router to allow external connections to be routed to your IIS computer;
    • Determine your machine’s local IP, or your MAC Address;
    • Configure in your router the function of port Forwarding, indicating that any external connection to ports 80 (HTTP) and 443 (HTTPS) is routed to your server (via IP or MAC Address);
  • Set up a dynamic DNS service so that your machine has a 'name' on the internet - otherwise users will only be able to access your service if they know your IP (which, being dynamic, will be changed periodically). Some options:

This will allow you to offer your Webapi to the internet in general. However several other points should be considered:

  • You are opening your machine to the internet, and are a potential target for malicious users;
  • The amount of users you can serve is limited by your speed/quota of upload - which is usually quite low in non-commercial contracts;
  • Access providers in Brazil usually do not like users offering services directly, so check if your contract with your access provider allows this type of setup.
  • Thank you for the very full reply, I will give a studied, in case you manage to resolve I mark as reply.

1

So I ended up finding a Post on the website of dotnetmentors.com, where the author ends up giving various explanations of how to host ASP.NET Web API on IIS using Visual Studio being one of the methods present in the program itself.

There the author cites two types of Lodging: Self Hosted, IIS hosting

IIS hosting (which is the method you want), is well detailed as shows below:

Host Customerapp on IIS
IIS manager opened by clicking Windows Start -> Run -> type inetmgr -> click OK

If IIS is not installed on your computer, click here to install.

Go to the IIS manager and right-click on locations and select -> -> Add site .

Add a new website to IIS

Enter the details as shown in the image below

Insert site name as Customerapp
Change the application grouping to ASP.net V4.0
Choose the physical path of the folder containing ASP.NET Web published API. -> I entered as C: Customerapp
Enter the port number on which you want to host API. I use the port -> as 9810.

Links:
dotnetmentors.com
Google

  • 1

    Link responses are discouraged here. Try to add context of what is being said in the link, so that it is only a reference, and not the answer.

  • It’s still the same, you just added more links, which actually made the answer worse. -1

  • @Diegof, '-', I still don’t get it

  • Visit [Answer] and (MAINLY) here. A link should only be referenced, not contain the entire answer to the question.

  • @Daniel this publication does not show how I can access from outside the local network (externally), which is my need, but was worth the effort.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.