Retrieving Client IP in code

Francis Carroll asked on August 10, 2022 12:42

Hi,

I have a live site in Knetico 13.0.78 using .net core and hosted on IIS 10.

In the code i am trying to retrieve the IP address of the client. I have used code with .NET core but this is returning the IP of the Server and not teh clients IP.

Does kentico have a function for retrieving this data?

Recent Answers


Sander Geerts answered on August 10, 2022 13:26

This does not seem Kentico related. If you're just running a .NET Core website, you should be able to retrieve the client's ip address through the current request like so:

var clientIpAddress = Request.HttpContext.Connection.RemoteIpAddress;
0 votesVote for this answer Mark as a Correct answer

Brian McKeiver answered on August 15, 2022 23:24

1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.