7

I have an asp.net core project running on IIS Express. The URLs (http://localhost:53142/ and https://localhost:44374/) work if I type into my browser as localhost, however, if i put in my IPv4 ip address (192.168.1.72) they don't work.

enter image description here

Side-by-side

enter image description here

I can ping the 192.168.1.72 address just fine.

enter image description here

Why can't I access via ip, and how would I do so?

Reza
  • 5,314
  • 5
  • 21
  • 35
  • The site bindings simply accept localhost requests only, https://docs.jexusmanager.com/tutorials/binding-diagnostics.html If you want to access via IP, you need to modify the bindings. – Lex Li Feb 03 '19 at 15:19
  • And how/where would I modify – Reza Feb 03 '19 at 15:21
  • Either manually or via a tool like Jexus Manager, https://docs.jexusmanager.com/getting-started/features.html#background – Lex Li Feb 03 '19 at 15:22
  • I installed Jexus Manager and got my project on there. But its not clear at all how I can run a debug from inside VS2017, and then have Jexus give me an ip address. – Reza Feb 03 '19 at 20:07
  • First, add a binding that accepts access via IP. Then test and make sure that Jexus Manager can start the site and the browser works. And lastly you go back to VS and sync the settings. – Lex Li Feb 03 '19 at 20:12

3 Answers3

9

IIS Express does not allow remote connections by default.

Here are two options for you:

  1. Configure to use UseKestrel like

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseUrls("http://0.0.0.0:5000;https://0.0.0.0:5001")
            .UseKestrel()
            .UseStartup<Startup>();
    

    Then, run project with ProjectName from VS, you will be able to access by http//ip:5000

  2. Try to create IIS Debug profile

    Run VS 2017 as administrator-> Right Click project-> Properties->Debug->NEW->Enter IIS->Launch choose IIS-> Launch IIS Profile-> Access with ip address

Update:

If you insist on IIS Express, try the VS Extension Conveyor by Keyoti

Edward
  • 28,296
  • 11
  • 76
  • 121
3

There is a little open-source github repository to make this work. it is a small portable executable (.exe) app that makes your API (port actually) accessible via local network.

sharp proxy

repo link: https://github.com/jocull/SharpProxy

hhk
  • 508
  • 7
  • 15
0

There is a simpler solution if you have admin access to your pc, https://stackoverflow.com/a/11535395/167304

Given web app running on localhost:1234 with ip 10.10.10.10:

netsh interface portproxy add v4tov4 listenport=1234 listenaddress=10.10.10.10 connectport=1234 connectaddress=127.0.0.1

When no longer needed, delete the record

netsh interface portproxy delete v4tov4 listenport=1234 listenaddress=10.10.10.10

For more detail see netsh interface portproxy add v4tov4

Jason
  • 3,844
  • 1
  • 21
  • 40