Question

I'm trying to read web resource fron within the C# code. Unfortunately the code is valid only when running from local drive and throws exception when running from network share (and that's what I need).

The underlying connection was closed: Unable to connect to the remote server.
   in System.Net.HttpWebRequest.GetResponse()
   .........
Caused by: 
An invalid argument was supplied
   in System.Net.Sockets.Socket..ctor(AddressFamily addressFamily, SocketType socketType, ProtocolType protocolType)
   in System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
   in System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
   in System.Net.Connection.CompleteStartConnection(Boolean async, HttpWebRequest httpWebRequest)

I've tried code similar to (this throws the exception):

request = (HttpWebRequest)WebRequest.Create(url);

as well as direct socket connection according to http://msdn.microsoft.com/en-us/library/2b86d684.

I have a suspicion there is some sort of security setting in Windows that prevents network connections. Is it possible to solve this? Via AD policy? Or something in my code?

Was it helpful?

Solution

You could start here The Project Location is Not Trusted Dialog Box. Quote:

By default, a UNC path is not a trusted location for a project. You can modify the security policy of the file share to prevent this dialog box from appearing. For more information, see Configuring Security Policy.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top