2

I have a web core api server and I'm trying to connect to it from my phone, but it just says connection failed every time I try. Is it possible that the IIS Express Server doesn't make my IP address available for remote devices? I've done this once using Java and it worked perfectly fine, I don't understand why it won't work here.

public class Program
{
    public static void Main(string[] args)
    {
        BuildWebHost(args).Run();
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseUrls("http://localhost:8080", "http://myIP:8080")
            .UseStartup<Startup>()
            .Build();
}
M. Chris
  • 161
  • 2
  • 14
  • 1
    I think this help you.[How to enable external request in IIS Express](https://stackoverflow.com/questions/3313616/how-to-enable-external-request-in-iis-express) – vahid tajari Jan 03 '19 at 15:36

1 Answers1

4

Try

.UseUrls("http://*:8080")

This makes the server listen to all IPs of the computer

This only works when executing the app itself, not via IIS / IISExpress

Also, make sure the firewall allows http traffic on port 8080

Varty
  • 353
  • 1
  • 4
  • 1
    Thank you! I just ran the Application directly without IIS Express and it worked just fine. – M. Chris Jan 04 '19 at 08:49
  • 1
    You should only use this setup for developing. For production IIS is recommented. (the external access will work in IIS, although note that UseUrls will have no effect, the port is configured in the website bindings) – Varty Jan 04 '19 at 09:00