Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebClient, what does UploadString do? [duplicate]

Tags:

.net

webclient

What does WebClient.UploadString do?

I thought it post so i can login with it. When i used wc.UploadString(@"http://mysite.com/login", "user=u&pass=p"); i thought i would get the html of the front page with me logged in. However all i got was no warning that my pass was incorrect and my method=post note at the bottom.

What does WebClient.UploadString really do? and how can i login with WebClient?


1 Answers

The second parameter is passing data in the post body. You've formatted it to be part of the querystring. If the username/password are really passed in the querystring they should be included in the first parameter (the url). Otherwise, which is more likely, if they are to be sent as form parameters, then use UploadValues as Andrei suggested.

like image 181
Frank Schwieterman Avatar answered May 23 '26 02:05

Frank Schwieterman