-2

*

Exception =System.Net.WebException: Access to the path 'c:\windows\system32\inetsrv\Dialer' is denied. ---> System.UnauthorizedAccessException: Access to the path 'c:\windows\system32\inetsrv\Dialer' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at System.Net.FileWebStream..ctor(FileWebRequest request, String path, FileMode mode, FileAccess access, FileShare sharing) at System.Net.FileWebRequest.GetRequestStreamCallback(Object state)
--- End of inner exception stack trace --- at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request) at System.Net.WebClient.UploadString(Uri address, String method, String data)

*

Code where the exception is occurring

using (var writer = new StringWriter())
    {
       JsonSerializer.Create().Serialize(writer, payLoad);
       var result =client.UploadString(commDialerApiUrl,writer.ToString());
       return ((T)JsonConvert.DeserializeObject(result, typeof(T)));
    }

I know the code above is not ideal, however I just need to understand why even an attempt to access is made. Can anyone provide some insight please?

lalatnayak
  • 160
  • 1
  • 6
  • 21
  • Well, you have the cause of the problem in clear text! What more can you ask for? =) – Daniel B Aug 24 '15 at 14:59
  • why don't you check to make sure you have access to the folder if worse come to worse run you application as Administrator or right click on your visual studio shortcut and click run as administrator and see if it works.. otherwise set the folder permissions – MethodMan Aug 24 '15 at 15:05
  • If your question is 'why is this code even trying to access 'c:\windows\system32\inetsrv\Dialer' then can you confirm what you have in commDialerApiUrl please? – tolanj Aug 24 '15 at 15:29
  • The Url is of a WCF REST API. Yeah I'm more interested in knowing why the attempt to access is being made. I realize that if I give access to the folder, it will work. – lalatnayak Aug 24 '15 at 15:36

1 Answers1

2

All right, the issue was very simple. The code was trying to make a Restful post to a blank Uri. Since the Uri was blank webclient was trying to resolve the call to a file (having the same name as the service) in inetpub.

Since no such file path was invalid, thus the i/o error.

lalatnayak
  • 160
  • 1
  • 6
  • 21