Sergio
Sergio

Reputation: 8269

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?

Upvotes: 1

Views: 1767

Answers (2)

Steven Robbins
Steven Robbins

Reputation: 26599

If you are struggling to get to the bottom of it Fiddler might shed some light. You will have to manually edit your code to go through the Fiddler proxy, but once that's done you can compare the IE result to the code one.

Upvotes: 1

ericp
ericp

Reputation: 611

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.

Upvotes: 1

Related Questions