Accessing IISExpress for an asp.net core API via IP

微笑、不失礼 提交于 2020-03-20 05:21:59

问题


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.

Side-by-side

I can ping the 192.168.1.72 address just fine.

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


回答1:


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



来源:https://stackoverflow.com/questions/54500310/accessing-iisexpress-for-an-asp-net-core-api-via-ip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!