SocketException when calling a WCF service from MVC on the same server

I have Windows 2008 Server with IIS 7.5 and one IP. In the root, / web and / service there are two applications. / web is an MVC4 application, and / service is a WCF 4.0 service.

When I use the service from MVC, I use the following code:

// Create the web request HttpWebRequest request = WebRequest.Create(TripServiceUrl + id) as HttpWebRequest; // Get response using (HttpWebResponse response = request.GetResponse() as HttpWebResponse) { // Get the response stream StreamReader reader = new StreamReader(response.GetResponseStream()); // Console application output tripJson = reader.ReadToEnd(); } 

I get the following SocketException:

 [SocketException (0x274c): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 10.243.6.43:80] System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) +273 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) +584 

However, I can see 10.243.6.43:80 (internal address) from the browser on the server and successfully call the service. IP is not publicly available.

What configuration do I need to do to make my own reference call the way it works?

+8
c # asp.net-mvc asp.net-mvc-4 wcf
source share
1 answer

This is probably a problem with loopback (security issue). See http://support.microsoft.com/kb/896861 .

Summarizing:

In the registry editor, locate and then click the following registry key: HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ LSA Right-click Lsa, select New, and then DWORD Value. Type DisableLoopbackCheck and press Enter. Right-click DisableLoopbackCheck and choose Modify. In the Value field, enter 1 and click OK.

Do not follow DisableStrictNameChecking directions.

You will also find many reasons not to do this (you will turn off the security check after all), and then many people say that this is the only way to get SharePoint to work correctly. In any case, this will help you determine if this is a problem.

+1
source share

All Articles