SharePoint EnentHandler 获取客户端IP地址

xutw456 2009-12-08 11:42:51
大家好,我遇到个问题请教一下各位。
我目前有个项目需要实现DocumentLibrary上的Eventhandler, 其中需要在Eventhandler中获取触发该事件的客户端的IP地址,
各位有没有遇到过类似问题,烦请指点一下,不胜感激!
...全文
95 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
time_is_life 2009-12-08
  • 打赏
  • 举报
回复
EventHandler是无状态的,不能获取。
xutw456 2009-12-08
  • 打赏
  • 举报
回复
???????
long3957 2009-12-08
  • 打赏
  • 举报
回复
KKKKKKKKKKKKKKKKKKKKK
xutw456 2009-12-08
  • 打赏
  • 举报
回复
hi,helimin19
这个方法好像不行哦,HttpContext.Current这个对象根本拿不到, 提示“object reference not set to a object”
helimin19 2009-12-08
  • 打赏
  • 举报
回复
public static string ClientIP
{
get
{
string ip = String.Empty;
if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] != null) // using proxy
{

ip = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"].ToString(); // Return real client IP.
}
else // not using proxy or can't get the Client IP
{
ip = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(); //While it can't get the Client IP, it will return proxy IP.
}
return ip;
}
}
xutw456 2009-12-08
  • 打赏
  • 举报
回复
高手帮帮忙~~~

3,245

社区成员

发帖
与我相关
我的任务
社区描述
企业开发 SharePoint
社区管理员
  • SharePoint社区
  • 霖雨 - LinyuLoveTJ
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧