如果客户端请求我的api,如何知道客户端IP地址和网站URL? [英] How to know client IP address and website URL if client request my api?
问题描述
如果我在c#.net中为任何通用用户创建了一个api。
api URL是
http:// mydomainname .com / api / clientinfo
没有任何参数。
和其他客户在他们的网站上使用我的上述api www.clientdomain -name.com ,其IP地址 101.101.101.101 (示例)。
当我的客户端访问我的api时( http://mydomainname.com/api/clientinfo )使用jquery或任何其他方式然后我想返回作为响应他们的详细信息如下json字符串:
{url:www.clientdomain-name.com,ip:101.101.101.101,静态:false,状态:成功}
如何在C#.Net web api控制器中获得以上结果?
我尝试过:
如何获得上述问题的输出?
参考 - c# - Asp Net Web API 2.1获取客户端IP地址 - 堆栈溢出 [ ^ ]
If I have create an api for any universal user in c#.net.
api URL is
http://mydomainname.com/api/clientinfo
without any parameter.
and other client is using my above api in their website www.clientdomain-name.com and its IP address is 101.101.101.101(example).
when my client access my api (http://mydomainname.com/api/clientinfo) using jquery or any other way then I want to return as response their details like below in json string:
{url: "www.clientdomain-name.com", ip: "101.101.101.101", static:"false", status: "success" }
How can I get above result in C#.Net web api controller?
What I have tried:
How can I achieve output for above question?
Refer - c# - Asp Net Web API 2.1 get client IP address - Stack Overflow[^]
这篇关于如果客户端请求我的api,如何知道客户端IP地址和网站URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!