Display IP address from client in a report

Last post 09-06-2007 9:37 AM by shados. 3 replies.

Sort Posts:

  • Display IP address from client in a report

    09-05-2007, 8:31 PM
    • Star
      12,114 point Star
    • shados
    • Member since 07-07-2006, 7:24 PM
    • Posts 2,201

    I know that may seem like a weird request, but bear with me. I have multiple possible web sites that would request a report from a given Report Server, and I'd like the IP address of whatever machine requested the report to be displayed somewhere on said report. Is there a way to achieve this?

    Thank you!

    NOTE: To simplify things, I literally want to display whatever IP the reporting server sees. No need to think complicated about if its a server, a client, etc. Just whatever IP the report server is seeing.

  • Re: Display IP address from client in a report

    09-06-2007, 3:14 AM
    • Member
      193 point Member
    • Blackat.NET
    • Member since 05-18-2007, 12:41 PM
    • Catania, Italy
    • Posts 47

    You can use a parameter in query string that contain IP address of the server macchine that require the report. 

    --
    Harder Better Faster Stronger - My Blog
    Salvo Davide Rapisarda
  • Re: Display IP address from client in a report

    09-06-2007, 3:26 AM
    • Participant
      978 point Participant
    • ngruson
    • Member since 10-26-2006, 1:55 PM
    • Rotterdam, The Netherlands
    • Posts 197

    You can get a client's IP address by:

    string GetIPAddress()
    {
        return HttpContext.Current.Request.UserHostAddress;
    }

     

    You can put this code in a custom assembly. You can call this assembly in your report: http://geekswithblogs.net/davyknuysen/archive/2007/03/26/109901.aspx

    Nils Gruson
    Microsoft .NET Consultant (MCPD)
    Logica



    You don't have to be sick to get better.

    Please remember to click “Mark as Answer” on the post that helped you keep your job.
  • Re: Display IP address from client in a report

    09-06-2007, 9:37 AM
    • Star
      12,114 point Star
    • shados
    • Member since 07-07-2006, 7:24 PM
    • Posts 2,201

    I thought about embedding code, but unfortunately, the Request object is not set in a report (had to import System.web in it first to test that).

    And sending the IP as a parameter would be the easy way, with a catch: Servers tend to have a lot of IPs, even more so if you include the IPv6 ones. Its difficult to "guess" which one is exposed to the server. Can do some tricks using subnet masks and such, but the ideal would be for the server to find it, itself.

    My plan B is to have a config in machine.config or something (multiple apps need it, not just web) with the IP as a key, and we'll have to make sure not to forget to change it, or something...

Page 1 of 1 (4 items)