[英]How can I crop the area containing the recipient's details in a mail through Image Processing in C#?
[英]How can I get recipient ip address and location when Recipient opens my mail?
客戶端打開我的郵件時如何獲取客戶端IP和地址? 我試過這個:
var ip = HttpContext.Current.Request.Params["HTTP_CLIENT_IP"] ?? HttpContext.Current.Request.UserHostAddress;
IpInfo ipInfo = new IpInfo();
string info = new WebClient().DownloadString("http://ipinfo.io/" + ip);
ipInfo = JsonConvert.DeserializeObject<IpInfo>(info);
RegionInfo myRI1 = new RegionInfo(ipInfo.Country);
obj.country = myRI1.EnglishName;
obj.countryCode = myRI1.ThreeLetterISORegionName;
obj.state = ipInfo.Region;
obj.city = ipInfo.City;
obj.ip = ipInfo.Ip;
但這會返回我的主機服務器地址
為了解決您的問題,您可以添加以下代碼:
obj.ServicePoint.BindIPEndPointDelegate = new System.Net.BindIPEndPoint(BindIPEndPointCallback);
如果此代碼位於Web服務中,則可能是您的應用程序在自身與服務之間創建代理而不是將其直接連接到瀏覽器時遇到了問題。
[Browser] ---> [ASP.NET App / Proxy] ---> [Web Service]
這可以解釋為什么服務始終將服務器的IP地址視為客戶端,因為從Web服務的角度來看,ASP.NET應用程序是它的“客戶端”。
在這種情況下,您將需要在應用程序層收集客戶端IP地址,並將其傳遞給Web服務。
Collect IP Address Here
|
V
[Browser] ---> [ASP.NET App / Proxy] ---> [Web Service]
^
|
Pass IP to web Service
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.