Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing IISExpress for an asp.net core API via IP

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?

like image 460
Reza Avatar asked Feb 03 '19 05:02

Reza


People also ask

Can I access IIS Express from another machine?

Normally when you run an application in IIS Express, it's only accessible on http://localhost:[someport]. In order to access it from another machine, it needs to be bound to your public IP address as well. Open* D:\Users[YourName]\Documents\IISExpress\config\applicationhost.

How can I access ASP NET app from another computer on the same network?

Control Panel > Windows Firewall > Advanced Settings > Inbound/Outbound rules. Add a new rule to both, specifying your port number and a generic name to identify its purpose. Thanks for the answer, I've just done that.

How do I get client IP address in asp net core?

Client IP address can be retrieved via HttpContext. Connection object. This properties exist in both Razor page model and ASP.NET MVC controller. Property RemoteIpAddress is the client IP address.

How do I change my localhost IP address to IIS Express?

Right click the systray icon, show all applications. Choose your site, and then click on the config link at the bottom to open it. I'd suggest adding another binding entry, and leave the initial localhost one there. This additional binding will appear in the IIS Express systray as a separate application under the site.


1 Answers

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

like image 107
Edward Avatar answered Sep 23 '22 00:09

Edward