ASP.NET asmx获取客户端ip, 请求ip, WebService中如何获取客户端的ip

ASP.NET asmx获取客户端ip, 请求ip, WebService中如何获取客户端的ip

this.Context.Request.UserHostAddress.ToString();

using System.Web.Services;

namespace WeChatPortal.WebService
{
    /// <summary>
    /// Summary description for WebService1
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]

    public class WebService1 : System.Web.Services.WebService
    {
        [WebMethod]
        public string HelloWorld()
        {
            return this.Context.Request.UserHostAddress.ToString();
        }
    }
}

作者最新文章
C# 使用 CSVHelper 操作 csv 文件, .net core, .net framework 读取写入 csv 文件
C# 实现字符串文本换行的方法,文本如何换行
C# 如何循环读取文件每一行文本内容
C# DateTime AddMonths 的错误用法导致跳过日期
C# 全角转换半角,半角转换为全角