Get client IP address [Not Host] in C# .NET web services

I create one web service using c# .net and in this web service I want to get an IP address for client. I check thousend of article but that is not working, let me give you one example

System.Web.HttpContext.Current.Request.UserHostAddress;
System.Web.HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];

This is gives me IP but that my server ip where I put my web service but I want to get my client IP address.

Can someone help me with this.
http://www.codegroups.com/blog/
0
shaileshk
10/23/2008 12:33:32 PM
asp.net.security 27051 articles. 1 followers. Follow

1 Replies
4275 Views

Similar Articles

[PageSpeed] 54

You can try:

string ip;

ip=Request.ServerVariables("HTTP_X_FORWARDED_FOR");
if(ip==string.Empty)
{
ip=Request.ServerVariables("REMOTE_ADDR");
}


REMOTE_ADDR does not always provide the users IP but rather the ISPs' IP address so first test HTTP_X_FORWARDED_FOR as this one is the real user IP.


Mohamed Abb@s



------------------------

Please remember to click “Mark as Answer” on the post(s) which helps you !
0
bmwz9
10/23/2008 1:11:44 PM
Reply:

Similar Artilces:

WS-Security with VS.NET 2005 Web Service and .NET 1.1 Client
We ship a webservices client piece into the field which is required to run on the .NET 1.1 version of the framework, this is defined by our business people and cannot change. We would like to work with .NET 2.0 in VS.NET 2005 for the backend Web Service piece. We are able to get the 2 to communicate fine and it is not a problem. The issue now is that we need to introduce security through WS-Security. I have not been able to find much information about interop between the 2 environments and WS-Security and cannot get the security elements to be invoked in VS.NET 2005. Currently we are trying ...

How to call a .net web service from another .net web service?
Hi all,I have developed two asp .net web services using visual studio .net 2003.I wish to call one web service from another web service.I tried adding a web reference of the web service in another web service and was able to do so.but i m not able to access the web methods provided by the web servicecould you please suggest a way to go about itExpecting quick replyThanxCharmy try to make sure that you reference it in the web reference and call it properly this is sample  [WebMethod()] public double CalcDistance(int x1, int y1, int x2, int y2) { Calculator.Service1 calc = new...

.NET CLIENT TO ACCESS a non. NET WEB SERVICE
I develop in .net and need to create a web client to connect to a web service built in Java. http://xchainj.com:8080/axis/services/ScsEnvirodatWaterQualityIndexServiceSoap Its pretty easy when the web service was also built in .net. You can just create a web reference with the gui and automatically can see its functions and stuff. when i put this url in the box and hit go i dont get to see its functions. maybe this shouldnt be the url of the WSDL?? I Have no idea. Im very new to all of this. If there are any examples of .net clients connecting to non .net web clients it woul...

Developed C#.net WebService 1.1 for Client C#.net 1.1. Getting error "Server was unable to process the Request" Pls Help
Hi., I developed Microsoft C#.net Web Services2003 for the Client Application C#.net 2003. When it runs in 5 machines it gives good performance and has no errors. But if i run the same application in about 80 client machines. Getting error "Server was unable to process the request". I use Sql Server 2005 as my database. I get error even when i login at a time for about 25 users. Tried modifying machine.config too. But went unsuccessful. Live Server is 2003 using IIS 6.0 I use very expensive data handling.  Its very urgent pls help. Have to post in Live Server. Thank u., ...

C#.NET in VS.NET vs. C# in Web Matrix
Hi all, I am very new to .NET ... I realized C#.NET is only available from Visual Studio.NET ... however, I realized Web Matrix also allowed us to choose C# as language but not C#.NET ... they are not the same, right? If not, then why it's in Web Matrix which runs ASP.NET?? If I need to run C#.Net, I MUST GET VS.NET, right? Can C#.NET has the abality to create chat program? Thank you very much. C#.NET and C# are the same thing. JimMS MVP ASP.NET [VC++/MFC emeritus]Old Dog Learns New TricksPreferred programming language: cuneiform on clay tablets So ... that means I can use web matrix t...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

Issue with clients consuming a web service that was upgraded from .NET 1.1 to .NET 3.5
I am currently working with an application that was converted from Visual Studio 2003 to Visual Studio 2008 and we are having issues with a client consuming the web service portion of the application.  The web services were written in .NET 1.1 using the Web Services Enhancements 2.0 and was upgraded to use the .NET 3.5 framework.  One of our clients application, which is still written in .NET 1.1 was reference the upgraded web service and tried to consume the web service and received the following error: System.Web.Services.Protocols.SoapException: Se...

Call a SECURED (with glassfish) Java EE Web Service from a .Net Client
Hi, Im trying to call a java web service in visual studio 2008 using a simple forms application. The problem that I'm running into is with the security. Can someone point me in the right direction as far as calling a secured java EE web service using .Net? Thanks. Adam Im unfamiliar with glassfish, however if the web service's security is WS-Security compliant, then you'll have to use WSE 3.0 (addon by Microsoft to make web services more useful) or Windows Communication Foundation. Thanks for the reply. Can you point me in the direction of using WSE to call a java...

Converting windows application using web service from Visual C#.net 2003 to Visual Studio.net 2005
Hello, everyone! I have a solution which contains a windows project,a web service project and several other library projects. These projects were coded under visual c#.net 2003. Now I need to converted them to use Visual Studo.net 2005. Does any one know any article providing step-by-step guide  to converting WINDOWS APPLICATION with web service? I can find one under MSDN for converting web project.  But I guess I am a little confused if mine should follow this article since I am using web service in my windows application? Thanks a lot in advance.  ...

Can you return .net web controls in a .net page from a web service?
I've got a problem with a project. I've got to compile an entire .net page and return it as part of a Web Service for display. The problem I have is that I need to add WebControls and functionality to the page so that not only the html content and images are displayed (which I've managed) but that textboxes, labels, buttons and datasets can be displayed also. Essentially I need to make a call from one site for a page, populate the page and return it in a state as though it resided on the same server/webspace as the calling page. Code is currently built as follows into a string: strOpenHT...

c# .net web service deployment
Hi all, I've written a web service in C# ..NET and i have deployed this project by including windows installer web project. Everything runs fine on the remote machine but i wanted to know how i could include in the setup a way to change the IIS directory security settings to anonymous access. Currently i'm setting up the project and then manually changing the settings. I've read stuff on the web about  how you can write custom action scripts to do this but i cannot find a good example of one - in fact the information i've found so far has been less than useless. Any he...

Exception while calling .NET web service | System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
Hi,   We have written a .NET web service which retrieves an xml file from the database. This web service is SSL secured and requires client certificates for connection.   Problem: The web service is throwing an exception while retrieving large files. It works fine when the file size is around 1 MB, but fails with a file size of around 65 MB with the following exception: System.InvalidOperationException: There is an error in XML document (1, 38455668). ---> System.IO.IOException: Unable to read data from the transport connection. ---> System.Net.Sockets.SocketException: ...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

Web service in .NET from Java Web Service
Hi there,I'm pretty new to .net (although i have years of experience with the old vb 6, access 2k, as well as java)... and need some with perhaps either some syntax or something.Here is the wsdl.<wsdl:definitions targetNamespace="http://www.dynix.com/schema/book">−<wsdl:types>−<schema targetNamespace="GetBookInfoByISBN">−<complexType name="BookInfoType">−<sequence><element maxOccurs="1" minOccurs="0" name="Title" nillable="true" type="xsd:string"/><element maxOccurs=&quo...

Web resources about - Get client IP address [Not Host] in C# .NET web services - asp.net.security

United States Department of Health and Human Services - Wikipedia, the free encyclopedia
The United States Department of Health and Human Services ( HHS ) is a Cabinet department of the United States government with the goal of protecting ...

Manila calling: Public Service's Philippines frolic revealed
Outsourcing giant takes Tax Office work to south-east Asia.

ESPN president says Apple ‘frustrated’ over building TV service, expects new packages in 2016
... Apple reportedly hopes to offer on its set-top box, the ESPN exec says that Apple has been “frustrated” with the process of building a service ...

HBO Plans to Take On Netflix in Spain With Streaming Service
HBO plans to start a stand-alone Web service in Spain, opening a new front against Netflix Inc. in an increasingly global competition for cord-cutters. ...

Jay Z's music streaming service Tidal accidentally took money from former customers
Tidal, the music streaming service owned by rapper Jay Z and a host of other musicians, has accidentally reactivated the accounts of former customers ...

More evidence of Apple’s frustrating fight to build TV service
... of ESPN, talked quite a bit in an interview about the future of Apple TV and in particular, Apple’s plans for a streaming television service ...

Verizon Tests Net Neutrality With 'FreeBee' Zero Rating Service -
... on "zero rating," or the controversial practice of exempting some data from customer usage caps. Verizon's new " FreeBee " sponsored data service ...

HBO is bringing a cord-cutter streaming service to Spain
HBO's planning to introduce a standalone streaming service in Spain, Bloomberg Business reports. The TV network is said to be eager to take on ...

Twitter Shares Suffer Outage Far Worse Than Its Service Did This Morning
Twitter experienced technical problems today that caused an outage of over 6 hours in duration. The world could live without Twitter for a few ...

Microsoft relaunching MinecraftEdu as a subscription-based service
Microsoft has acquired MinecraftEdu and will make the popular Minecraft-themed mod created by teachers for teachers to use in the classroom available ...

Resources last updated: 1/20/2016 12:40:36 AM