• This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts

  • kevin
    Keymaster
    Postcount 47

    Hello everyone,

    I want write log client ip address access my site. How can I get client IP address in ASP.NET Core Middleware?


    kevin
    Keymaster
    Postcount 47

    To get Client IP Address in ASP.NET Core Middleware you can use code below:

    public Task Invoke(HttpContext httpContext)
    {
    var ip = httpContext.Connection.RemoteIpAddress.ToString();
    var browserInfo = httpContext.Request.Headers["User-Agent"].ToString();
    Debug.WriteLine("IP: " + ip);
    return _next(httpContext);
    }

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Top