Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Retrieving clients ip adress on the server

Reply
Thread Tools

Retrieving clients ip adress on the server

 
 
Jason Wager
Guest
Posts: n/a
 
      11-20-2003
Hello,

I have looked a lot but not found how to do this:

I have a Web Services server and from this I want to see what IP adress the
Client (that connects to the SOAP server) has.
I want to do two things:
1) Restrict access to some specific IP adresses
2) Give different answers the different (allowed) IP adresses.

I don't know how to do either.

The first one, I suspect can be done with configuration.
The second one I need to be able to do from the code. That is, I hope that
there is a function that I can call, which tell me what IP adress the caller
has.
Otherwise, if someone can tell me how to look at the SOAP request as a low
level XML file in .NET (C# or VB.NET), I can find the answer for myself.

Thanks in advance
Jason


 
Reply With Quote
 
 
 
 
Saurabh Nandu
Guest
Posts: n/a
 
      11-21-2003
hi,

You can get the IP Address from the Request object within a Web Method.

As far as restricting IP's you could configure that directly in IIS manager,
this way the restricted IP's will never be able to call your web service.
Although I belive you need to be running a Server OS to enable IP
restrictions.

For the second part i.e. giving different responses based on the client's IP
can be solved by various methods.

1) In code check the IP address can then have switch statements to send back
different messages.
2) You could write your own HttpHandler that can invoke differernt methods
if required to provide differernt responses.

Regards,
Saurabh Nandu
[ MVP | Author ]


 
Reply With Quote
 
 
 
 
Jason Wager
Guest
Posts: n/a
 
      11-21-2003
Thank you for the reply.

Could you give me an example of this - perhaps including which classes that
are needed (Using ....).
I have tried looking at the documentation and all that I find are client
side functions for retrieving information from the server.

Thanks you again,
Jason

>
> You can get the IP Address from the Request object within a Web Method.
>
> Regards,
> Saurabh Nandu
> [ MVP | Author ]
>
>



 
Reply With Quote
 
Manni
Guest
Posts: n/a
 
      11-21-2003
Just use
Context.Request.UserHostAddress



HTH

Manfred


"Jason Wager" <(E-Mail Removed)> schrieb im Newsbeitrag
news:%23%(E-Mail Removed)...
> Thank you for the reply.
>
> Could you give me an example of this - perhaps including which classes

that
> are needed (Using ....).
> I have tried looking at the documentation and all that I find are client
> side functions for retrieving information from the server.
>
> Thanks you again,
> Jason
>
> >
> > You can get the IP Address from the Request object within a Web Method.
> >
> > Regards,
> > Saurabh Nandu
> > [ MVP | Author ]
> >
> >

>
>



 
Reply With Quote
 
Jason Wager
Guest
Posts: n/a
 
      11-21-2003
Thanks

I ended up using
Context.Request.ServerVariables["REMOTE_ADDR"]
I do not know if there is any difference between the two - they return the
same, it seems to me.

Another one just pointed me to this URL, which showed me the above code
http://www.dotnet101.com/articles/art033_servervars.asp

Regards,
Jason


"Manni" <(E-Mail Removed)> skrev i en meddelelse
news:%(E-Mail Removed)...
> Just use
> Context.Request.UserHostAddress
>
>
>
> HTH
>
> Manfred
>



 
Reply With Quote
 
Manni
Guest
Posts: n/a
 
      11-21-2003
Of course there is a differenc

Your code needs to use a textbase indexer
wich means searching somewhere to get an element of an array by
compareing text
and retrieves this "HTTP HEADER" value.

My code uses things CF had loaded to the elements of the Request object.
But since this is a porperty and I don't know the source this could
a.) be a call to some code simmilar to yours
b.) allways be loaded at initialisation of the page

So my code I think will be a little bit faster - espacially if they used B.

Otherwise - if find dealing with that object's property is better readable!

BUT: the value must be the same!!!

Manfred


"Jason Wager" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Thanks
>
> I ended up using
> Context.Request.ServerVariables["REMOTE_ADDR"]
> I do not know if there is any difference between the two - they return the
> same, it seems to me.
>
> Another one just pointed me to this URL, which showed me the above code
> http://www.dotnet101.com/articles/art033_servervars.asp
>
> Regards,
> Jason
>
>
> "Manni" <(E-Mail Removed)> skrev i en meddelelse
> news:%(E-Mail Removed)...
> > Just use
> > Context.Request.UserHostAddress
> >
> >
> >
> > HTH
> >
> > Manfred
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving the user on a remote machine by giving the IP adress hpber C++ 2 07-05-2007 02:43 PM
Authentication for web clients and Swing clients Francesco Java 1 12-27-2006 03:10 AM
IP Adress not renewing overnight David Wireless Networking 0 07-13-2004 03:18 PM
Server not serving ASP to some clients? Including Server itself! Scott Townsend ASP General 5 06-04-2004 02:19 PM
adress of server Jarod_24 ASP .Net 0 04-02-2004 03:31 PM



Advertisments