is there a popular C# library for working HTTP? Eg simplifing working with httpwebrequest etc -
Is there a popular C # library for working HTTP? For example, it is easy to work with httpwebrequest etc.
For example, in order to upload an http file with some parameters, knowledge of several lines and HTTP protocol content format is required. WebClient does not do this manually.
So being new, is there a well-known library that uses #developer?
Thanks
Web forms are stored in one of two formats: Application / X-www-form-urlcode and multipart / form-data .
The website provides a very easy and convenient way to upload any kind of data. In the case of application / x-www-form-urlencoded , whatever you have to do it is to provide one. In the case of multipart / form-data , AFAIK, you will have to create your request data (which may include both file and name value pairs).
Application / x-www-form-urlencoded
Name Awakening FormData = New NameVillelection (); FormData ["q"] = "c # webclient post urlencoded"; FormData ["btnG"] = "Google Search"; FormData ["hl"] = "n"; WebClient myWebClient = new webclient (); MyWebClient.UploadValues (Yuri String, FormData);
sets the HTTP method to "POST"
and content-type to "application / x-www-form -Urlncoded "
, URL-encod formData and specified
Yuri string
. multipart / form - data
string form data = @ "- AAB 03x content-displacement: form-data; name =" "Submit-Name" "Larry - AAB 03x Content-Form: Form - Data; Name =" "File" "File Name =" file1.dat "" Content-Type: App / Octet-Stream Content-Transfer-Encoding: Base 64 "+ Convert.tbase 64 string (file .readlbettes (" file1.dat "), Base64FormattingOptions.InsertLineBreaks) + @" --AaB03x-- "; WebClient myWebClient = New Webclient (); MyWebClient.Encoding = Encoding.ASCII; My WebClient.Headers.Add ("content-type", "multicast / form-data; limit = AAB 03x"); MyWebClient.UploadString (Yuri String, FormData);
Sets content-type to the limit used by "multipart / form-data"
sets HTTP method to "POST"
And uploads the byte array in uriString
. In this example, the request data contains the file file1.dat
and a form parameter submit-name
, Which is Larry
. Described in the format.
Comments
Post a Comment