How to get Client IP address in ASP.NET Core 2.1

前端 未结 7 856
再見小時候
再見小時候 2021-02-02 09:21

I\'m working on ASP.Net Core 2.1 with Angular Template provided by Microsoft Visual Studio 2017. My Client App is working fine. After competition of User Authentication, I want

7条回答
  •  忘了有多久
    2021-02-02 10:09

    If your Kestrel sits behind a reverse proxy like IIS make sure to forward the headers containing the client IP.
    This goes into startup:

    app.UseForwardedHeaders(new ForwardedHeadersOptions{ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto});
    

提交回复
热议问题