title: C# network connection running from shared drive
body: <p>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).</p>
  
  <pre><code>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&amp; address, Socket&amp; abortSocket, Socket&amp; 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)
  </code></pre>
  
  <p>I've tried code similar to (this throws the exception):</p>
  
  <pre><code>request = (HttpWebRequest)WebRequest.Create(url);
  </code></pre>
  
  <p>as well as direct socket connection according to <a href="http://msdn.microsoft.com/en-us/library/2b86d684" rel="nofollow">http://msdn.microsoft.com/en-us/library/2b86d684</a>.</p>
  
  <p>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?</p>