AngleSharp by Florian Rappl

<PackageReference Include="AngleSharp" Version="0.8.6" />

 DocumentRequest

public class DocumentRequest
Represents the arguments to load a document.
using AngleSharp.Dom; using AngleSharp.Html; using System; using System.Collections.Generic; using System.IO; namespace AngleSharp.Network { public class DocumentRequest { public INode Source { get; set; } public Url Target { get; set; } public string Referer { get; set; } public HttpMethod Method { get; set; } public Stream Body { get; set; } public string MimeType { get; set; } public DocumentRequest(Url target) { if (target == null) throw new ArgumentNullException("target"); Target = target; Referer = null; Method = HttpMethod.Get; Body = Stream.Null; MimeType = null; } public static DocumentRequest Get(Url target, INode source = null, string referer = null) { DocumentRequest documentRequest = new DocumentRequest(target); documentRequest.Method = HttpMethod.Get; documentRequest.Referer = referer; documentRequest.Source = source; return documentRequest; } public static DocumentRequest Post(Url target, Stream body, string type, INode source = null, string referer = null) { if (body == null) throw new ArgumentNullException("body"); if (type == null) throw new ArgumentNullException("type"); DocumentRequest documentRequest = new DocumentRequest(target); documentRequest.Method = HttpMethod.Post; documentRequest.Body = body; documentRequest.MimeType = type; documentRequest.Referer = referer; documentRequest.Source = source; return documentRequest; } public static DocumentRequest PostAsPlaintext(Url target, IDictionary<string, string> fields) { if (fields == null) throw new ArgumentNullException("fields"); FormDataSet formDataSet = new FormDataSet(); foreach (KeyValuePair<string, string> field in fields) { formDataSet.Append(field.Key, field.Value, InputTypeNames.Text); } return Post(target, formDataSet.AsPlaintext(null), MimeTypes.Plain, null, null); } public static DocumentRequest PostAsUrlencoded(Url target, IDictionary<string, string> fields) { if (fields == null) throw new ArgumentNullException("fields"); FormDataSet formDataSet = new FormDataSet(); foreach (KeyValuePair<string, string> field in fields) { formDataSet.Append(field.Key, field.Value, InputTypeNames.Text); } return Post(target, formDataSet.AsUrlEncoded(null), MimeTypes.UrlencodedForm, null, null); } } }