.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Problem with getting client's IP address in WCF service on IIS7

Posted By:      Posted Date: October 12, 2010    Points: 0   Category :WCF


I have deployed a WCF duplex service on IIS7 that gets the client's IP address and based on that if the IP address repeats, the client is not given access to service. The problem is that when I deploy it on IIS7 and try to access it from another PC on LAN, it identifies the new PC having the same IP address as the one that the service is deployed in(just for testing purpose, I am returning the retrieved IP address to client), and So, I am not able to access the service from another PC. 

Can anyone help me with this?



View Complete Post

More Related Resource Links

Problem to obtain client IP on web service



I'm having problems to obtain the client IP on web service. Here's my scenario:

One server with Windows 2003, hosting the web service using .Net Framework 2.0, with IP and host name ServerTransaction.
Other server with Windows 2003, hosting a web application using .Net Framework 2.0, that consuming the web service on  ServerTransaction, with IP and host name ServerApplication.
Many other computers on the local network (IPs:,,, ...) acessing the web application on ServerApplication.

On the code of the web service I've tried to use HttpContext.Current.Request.UserHostAddress or HttpContext.Current.Request.ServerVariables("REMOTE_ADDR") or HttpContext.Current.Request.ServerVariables("HTTP_X_FORWARDED_FORR"), but always I can only get the IP of ServerApplication (

Any idea or tip?

Thanks and sorry for my bad english.

WCF Service client problem.

Hi,I have hosted a wcf service over IIS with Windows Authentication. All the users are able to access the WCF service Url from their machine. The problem is that some of the user are able to consume the webservice method while few of them when try to consume the service ,the error is thrown connection - reset error.I have tried to go through the IIS log also but it did'nt helped.Can any one help me regarding this. What settings I need to check/change to solve the proble.Thanks,AKB

Metadata publishing for this service is currently disabled Problem under IIS7



I am struggling with an issue that I haven't seen before, at least not without a simple resolution. I have seen numerous articles about this issue but I haven't found one that actually gives a solution that works and its really becoming a royal pain.

I am getting the message, "Metadata publishing for this service is currently disabled" when attempting to host my service in IIS7 on windows 7. I have only seen this problem since I migrated to VS2010 using the .NET 4 Framework.

I have adjusted my web.config file in effort of resolving the problem but to no avail. Anyone here able to help me out on this one? I am totally exhausted on going in circles for this issue.

Here is my code:

<?xml version="1.0"?>
    <compilation debug="true" targetFramework="4.0" />
        <behavior name ="MapServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>

Cannot read Silverlight client ip-address in service


I'm using the following code to read the ip address and port from a client that connects to my service:

            //Read IP-address and port
            MessageProperties messageProperties = OperationContext.Current.IncomingMessageProperties;
            RemoteEndpointMessageProperty endpointProperty = messageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
            string ip = endpointProperty.Address;
            string port = endpointProperty.Port.ToString();

If I connect with a wpf client using netTcp binding I can read the proper ip adress and port number but if I connect with a SL4-client with the PollingDuplex the ip adress is empty and the port is 0. Why is that?

Thanks for help!

EDIT: I noticed that it works as supposed for Silverlight 3 so this seems to be SL4 specific.

Problem setting endpoint address URL dynamically at runtime in client


I have a WCF web service and clients running on separate windows server 2003 machines. I'm using windows integrated authentication to authenticate the clients. All of the clients and the service are running in appPools in IIS6 as specified active directory users. I have added the service as a service reference to the client project in Visual Studio 2008. This works fine in the development network. To run it in the Production environment I need to change the URL and the UPN at runtime to the production values, but whatever I try it just throws errors? In fact the only thing that worked - but isn't really practical - is when I removed the development service reference and added the production service reference to the project using Visual Studio before deployment. Surely there is some way to change the endpoint at runtime??? I must be missing something simple. Please help! :)

Here is the relevant part of the client endpoint:

         < endpoint address ="http://dev.happyfunland.com.au/FunService.svc" binding ="wsHttpBinding"

WCF durable service - retrieve token id on the client side problem



I've created WCF durable service (service class marked as DurableService) with SQL persistent provider. The client invokes the service method marked as DurableOperation(CanCreateInstance:=True), after this - service successfully creates entry in the InstanceData table in sql database. Inside the service I can access the token id by using



If I understand the concept of WCF durable services, client could get this token and use it later to recreate the service state. Here I have:

Dim proxyActionParserService As New ActionParserService.ActionParserWorkerServiceClient

Dim contextManager As IContextManager = proxyActionParserService.InnerChannel.GetProperty(Of IContextManager)()

problem compiling web service


Using Visual Studio 2010.

I created a webservice GetDemographicData asmx, GetDemographicData asmx.cs and then used wsdl to create a proxy, then used csc.exe to create dll.

first time when I generate proxy, it looks and works fine, but when I make some changes to my webservice and regenerate proxy the following problems occur:

1.I lost the function: public DataSet Get_GetDemographicData(string CaseNum, int Version)
2. The namespace changed to my-labs

Why?? Please see my code below:

Any help is appreciated. Thanks.

<%@ WebService Language="C#" CodeBehind="~/App_Code/GetDemographicData.cs" Class="GetDemographicData" %>
GetDemographicData.cs was created under AppDataas follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

/// <summary>
/// Summary description for GetCurrentReportVersion
/// </summary>
[WebService(Namespace = "http://localhost/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, u

problem in consuming WCF service through Window application


I have a silverlight application and WCF service all made in VS 2010 , i had hosted my site to web server which contain Window 2008 and IIS 7.0

now the problem is i have another application which is a window application developed in VS2008 , when i try to add the service reference it gives me error


The document at the url was not recognized as a known document type.

The error message from each known type may help you fix the problem:

- Report from 'DISCO Document' is 'There was an error downloading 'http://dev_qa.emspa.com/HRDev3/Service.svc?disco'.'.

  - The request failed with HTTP status 400: Bad Request.

- Report from 'WSDL Document' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.

- Report from '' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.

- Report from 'XML Schema' is 'The document format is not recognized (the content type is 'text/html; charset=UTF-8').'.

Metadata contains a reference that cannot be resolved: ''.

Content Type application/soap+xml; charset

Smart Client: Building Distributed Apps with NHibernate and Rhino Service Bus, Part 2


Smart client applications are responsive and promote interactivity with the user. In this article, we continue building a smart client application using NHibernate for data access and Rhino Service Bus for reliable communication with the server.

Oren Eini

MSDN Magazine August 2010

Smart Client: Building Distributed Apps with NHibernate and Rhino Service Bus


Smart client applications are responsive and promote interactivity with the user. In this article, we start the processes of planning and building a smart client application using NHibernate for data access and Rhino Service Bus for reliable communication with the server.

Oren Eini

MSDN Magazine July 2010

Extreme ASP.NET: Client-Side Web Service Calls with AJAX Extensions


Microsoft AJAX Library and the ASP.NET 2.0 AJAX Extensions provide a number of compelling features ranging from client-side data binding, to DHTML animations and behaviors. Learn all about them here.

Fritz Onion

MSDN Magazine January 2007

Looking for a simple Service and Console Client REST sample implementing BASIC authentication


Does anyone know of a C# code sample demonstrating WCF REST services and console test client with OperationContracts (GET and POST) implementing mutiple paramaters using BASIC authentication? Also, perhaps, using Fiddler as a test client as well? I have searched high and low for something like this, but have not had any success.

passing object values from server to client problem


I get a message that x_login is not declared.  I added Dim login as String = "123", but that didn't help.  What's the problem?

code behind....

Dim Login = "123"
x_login.Value = loginID


<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<form id="simForm" runat="server" method='post' action='https://test.authorize.net/gateway/transact.dll'>
        <input id="HiddenValue" type="hidden" value="Initial Value" runat="server" />
        <input type='hidden' runat="server" name='x_login' id='x_login' />
        <input type='submit' runat="server" id='buttonLabel' />



Problem with passing an Image as binary through web service



I have a web service that is accessed by a windows forms application and receives updates like facility name, address, image etc. Everything works fine except the image data is not being passed to the windows app. I am saving the images in database on both sides, so when I pull it from the server I use the following code

if (!reader.IsDBNull(floorPlanOrdinal))

facility.FloorPlan = (byte[])reader["FloorPlan"];

I can see the facility.FloorPlan Dimentions as 103840 when I debug this method which means that the data is pulled from the database fine.

On the forms side though the dimentions become 0, all other values pass fine except this. Here is the facility property in the web service on server side.

using System;

using System

Connection problem while connecting from client to server.

Hello, i am trying to connect sql server 2005 express using c#.net 3.5. my connection string is "Server=.\SQLExpress;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\db_naren.mdf;Database=db_naren; Trusted_Connection=Yes;" this is working fine when i am connecting to sql server from the local machine. When i am trying to connect from someother machine to server it is giving error like A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) i added previliges in add new administrator on SQL Server 2005 Surface Area Configuration . and i made changes on SQL Server 2005 Surface Area Configuration  page, on Database Engine --> Remote Connections -->Local and remote connections --> Using both TCP/IP and named pipelines. still same error i am getting from client machine i am using connection string as "Server=MyServer\SQLExpress;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\db_naren.mdf;Database=db_nare; Trusted_Connection=Yes;" is there any thing i need to do to connect from client machine to server?please

Cannot get service reference for Net.tcp service hosted in IIS7

HiI've got a service that I want to host in IIS7. The service runs over net.tcp (currently without security), but I am unable to create a service reference to it, or call it, using the net.tcp protocol. My event log is populated with lots of errors related to ASP.NET and System.ServiceModel, relevant services are installed and running (net.tcp port sharing service and net.tcp listener adapter).O/S : Window7 RTMDevStudio: 2008I publish the webservice to IIS7 and I get a valid page when navigating to the published .svc file (which tells me to use svtutil.exe and point it at the net.tcp endpoint).For that, I get this error :    The message could not be dispatched because the service at the endpoint address 'net.tcp://gedm-desktop.profiledc01.appdevelop.local/ManageAVMEP/ManageAVMAgent.svc/mex' is unavailable for the protocol of the address.Googling the problem leads me down several blind alleys :(I cannot determine what is causing the net.tcp listener to keep stopping? Everything is fine if I use the wsHttpBinding.Any tips or pointers to a course of action would be appreciated.ThanksGed My event log is full of errors (here is a sample) :-------An error occurred while trying to listen for the URL '/LM/W3SVC/1/ROOT/ManageAVMEP'. This worker process will be terminated. Sender Information: net.tcp Exception: System.ServiceModel.WasHos

WCF client to WSE 3.0 service

Dear all,   I try to create WCF client to WSE 3.0 service. I have already working WSE3.0 client to the same service. Here is it's configurations:   <microsoft.web.services3> <security> <timeToleranceInSeconds value="10000"/> <x509 allowTestRoot="true" verifyTrust="true" storeLocation="CurrentUser"/> <binarySecurityTokenManager> <add valueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"> <keyAlgorithm name="RSA15"/> </add> </binarySecurityTokenManager> </security> </microsoft.web.services3>   And the policy for the service client created in such a way:   MutualCertificate10Assertion assertion = new MutualCertificate10Assertion() { EstablishSecurityContext = false, RenewExpiredSecurityContext = true, RequireSignatureConfirmation = false, MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncrypt, RequireDerivedKeys = false, TtlInSeconds = 300 }; assertion.ClientX509TokenProvider = new X509TokenProvider(StoreLocation.LocalMachine, StoreName.My, "ClientCerfiticateName", X509FindType.FindBySubjectName); assertion.ServiceX509TokenProvider = new X509TokenProvider(StoreLocatio
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend