How can we capture IP address of User on K 13 dot net core?

Chandra Bhattarai asked on May 27, 2022 12:14

I was able to capture it on dot net but on K13 Xperience dot net core , i tried several alternative referencing from stack overflow too but non of them worked. I am using 13.0.68. Is there any helper of kentico to get IP address

Recent Answers


Brian McKeiver answered on May 27, 2022 17:55

The Kentico Xperience API does not directly support this for dot net core according to my understanding. However, if your dot net core live site is exposed directly to the internet (no proxy in the way), then the standard C# code samples should work. Typically via code that includes the ForwardHeaders and then using HttpContext to return the IP. See this documentation from Microsoft. Once that is hooked up you should then be able to use this in a Controller.

var remoteIpAddress = Request.HttpContext.Connection.RemoteIpAddress;

0 votesVote for this answer Mark as a Correct answer

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