webclient.uploaddata

WebClient.UploadData error: (401) Unauthorized


I'm getting this error... What is puzzling me is the fact that i do not have any type of security enabled for the page i'm invoking...

WebClient myWebClient = new WebClient();
myWebClient.UploadData(myUrl,"POST", myByteArray);

When i access directly to the page ( on ie ) it works fine, with the WebClient it's not working.

Anyone has a clue on what can be wrong?


Solution

  • IE supports integrated security, which will use your current login credentials as the username and password, so you don't have to manually enter it.

    If you are using IE, use Firefox and see if you are prompted for a username and password. Or, in IE, you can go to Tools, Options, Advanced, and uncheck Integrated Windows Authentication.

    Most likely, you'll have to configure the web application to support anonymous access, or you'll have to implement security in your WebClient.