hello,
I have this method in web api controller
Then from client when i call this method form my default.aspx page instead of user ip its returning server ip
But when i call it from swagger it shows the user ip
http://apiemis.highereducation.edu.sl/mthapiconsume.aspx
[Route("api/ip")]
public IHttpActionResult getip()
{
string ip = "Invalid";
string ipAdd = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(ipAdd))
{
ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
else
{
ip = ipAdd;
}
return Ok(ip);
}
object input = new
{
//incase if you want to pass search parameter to query
//Name = txtName.Text.Trim(),
};
string inputJson = (new JavaScriptSerializer()).Serialize(input);
WebClient client = new WebClient();
client.Headers["Content-type"] = "application/json";
client.Encoding = Encoding.UTF8;
//URL + MethodName + Authorizationcode
//string json = client.UploadString(Website_Helper.APIURL + "/GetStudent/091fab0b-283c-42b8-b544-8d07cd0c8cbf", inputJson);
string json = client.UploadString(Website_Helper.APIURL + "/ip", inputJson);
I want a method in web api controller so i can get user ip and show on my default through api call from page behind
please advice