English 中文(简体)
加快获得申请数字价值的方法,将IP地址列入协会。 NET
原标题:Fastest way to get numerical value of the request s IP Address in ASP.NET

取得客户数字格式(NOT THE STRING FORMAT)的最快途径是什么?

string format  : 223.255.254.0
numeric format : 3758095872

页: 1

    static public uint IPAddressToLong(string ipAddress)
    {
        var oIP = IPAddress.Parse(ipAddress);
        var byteIP = oIP.GetAddressBytes();


        var ip = (uint)byteIP[0] << 24;
        ip += (uint)byteIP[1] << 16;
        ip += (uint)byteIP[2] << 8;
        ip += byteIP[3];

        return ip;
    }

根据请求。 用户Host Address string,但我希望国际电联或伙伴关系。 NET预示着这一点,它藏在HttpContext。

我错了吗?

最佳回答

HttpContext似乎没有做比你已经看到的更大的礼貌:在中显示价值。 HttpRequest。 用户指南

www.un.org/Depts/DGACM/index_spanish.htm 一些背景信息:

<代码>HttpContext.Current.Request is of category System.Web.HttpRequest which take a System.Web.HttpWorkerRequestas para amount when Immediateiated.

<代码>HttpWorkerRequest是一种抽象的分类,即:在IIS的情况下,通过主办实施,<代码>System.Web.Hosting.IIS7WorkerRequest,然后执行抽象方法的<代码>GetRemoteAddress(,该编码在内部使用。 HttpRequest。 用户HostAddress

。 知道REMOTE_ADDR是其需要阅读的IIS财产,经过几层摘要,同时绕过请求范围,最后都以<代码>告终。 MgdGetServerVariableW(IntPtr pHandler, string pszVarName, out IntPtr ppBuffer, out int pcchBufferSize); in webengine. dll 仅写一段长度:pcchBufferSize,载于ppBuffer 页: 1 HttpRequest。 用户HostAddress。

Since i doubt that there are other parts in the HttpContext that get fed request-sender related information, i m assuming you ll have to keep doing your own magic for conversion for which there are plenty of ideas in the link i posted in the comments.

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签