Reputation: 65
I am trying to access a Web API Service written by me (currently hosted in a Console Application for ease) from anywhere without using a DDNS service. I know that the public IP could change, it doesn't matter. I will always have access to the new one. I'm just doing this for the fun of it.
So far, I did the following things:
The service is set to start on the address 192.168.1.101:50000 all the time. Also Cors is set to CorsOptions.AllowAll
Here comes my problem: when I make a request using Postman to the API using the local ip address and port, everything works as expected.
However, if I try accessing the public IP address with the same port, like so: public_ip:50000/ApiRoute I get a timeout regardless of the device (local machine or other device connected on same network or different) I make the request from;
The source of the public IP address is the ifconfig.co website.
Does anyone have any idea why the public IP doesn't work? I'm honestly out of ideas.
Upvotes: 4
Views: 2560
Reputation: 11
Try just putting an asterisk (*) in the base URL to be sure the API can be accessed from any IP address, just like this code:
using Microsoft.Owin.Hosting;
using System;
namespace WebApiDocker
{
class Program
{
static void Main(string[] args)
{
string baseAddress = "http://*:80/";
using (WebApp.Start<Startup>(url: baseAddress))
{
Thread.Sleep(Timeout.Infinite);
}
}
}
}
Upvotes: 1