Created
February 18, 2020 16:26
-
-
Save klpatil/8e3d1bbce0afc00a2ecef4f5e6b4f5bd to your computer and use it in GitHub Desktop.
Print User's IP Information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script runat="server"> | |
private void PrintInfo() { | |
Response.Write("Country " + Sitecore.Analytics.Tracker.Current.Interaction.GeoData.Country); | |
Response.Write("<br/>"); | |
Response.Write("AreaCode " + Sitecore.Analytics.Tracker.Current.Interaction.GeoData.AreaCode); | |
Response.Write("<br/>"); | |
Response.Write("City " + Sitecore.Analytics.Tracker.Current.Interaction.GeoData.City); | |
Response.Write("<br/>"); | |
Response.Write("XFWFOR " + HttpContext.Current.Request.Headers["X-Forwarded-For"]); | |
Response.Write("<br/>"); | |
NameValueCollection headers = HttpContext.Current.Request.Headers; | |
for (int i = 0; i < headers.Count; i++) | |
{ | |
string key = headers.GetKey(i); | |
string value = headers.Get(i); | |
Response.Write(key + " = " + value + "<br/>"); | |
} | |
foreach (string var in Request.ServerVariables) | |
{ | |
Response.Write(var + " " + Request[var] + "<br>"); | |
} | |
} | |
</script> | |
<ul> | |
<% | |
PrintInfo(); | |
%> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment