Class HttpExtensions
Namespace: TecnoPack.WebServer
Assembly: CO0002_Templ_FlowpackHMI_V00_26_M.dll
Provides extension methods for HTTP request and response handling.
public static class HttpExtensions
Inheritance
object ← HttpExtensions
Methods
GetUploadedFiles(HttpRequestBase)
Extracts uploaded files from a multipart/form-data HTTP request.
public static List<UploadedFile> GetUploadedFiles(this HttpRequestBase req)
Parameters
req HttpRequestBase
The HTTP request instance.
Returns
List<UploadedFile>
A list of
Remarks
This method assumes the request body is fully buffered in req.DataAsBytes and
that the request uses a valid multipart/form-data content type.
ParseFormUrlEncoded(HttpRequestBase)
Parses the request body as application/x-www-form-urlencoded into a dictionary.
public static Dictionary<string, string> ParseFormUrlEncoded(this HttpRequestBase req)
Parameters
req HttpRequestBase
The HTTP request instance.
Returns
Dictionary<string, string>
A dictionary containing key-value pairs from the form body. Keys are case-insensitive.
ReadJsonAsync<T>(HttpRequestBase)
Deserializes the HTTP request body from JSON into the specified type.
public static Task<T> ReadJsonAsync<T>(this HttpRequestBase req)
Parameters
req HttpRequestBase
The HTTP request instance.
Returns
Task<T>
A task containing the deserialized object, or default(T) if the body is empty.
Type Parameters
T
The type to deserialize into.
WriteJsonAsync(HttpResponseBase, object)
Serializes an object to JSON and writes it to the HTTP response.
public static Task WriteJsonAsync(this HttpResponseBase res, object value)
Parameters
res HttpResponseBase
The HTTP response instance.
value object
The object to serialize and send.
Returns
Task
A task representing the asynchronous operation.
WriteJsonAsyncChunked(HttpResponse, object)
Serializes an object to JSON and writes it to the HTTP response using chunked transfer.
public static Task WriteJsonAsyncChunked(this HttpResponse res, object value)
Parameters
res HttpResponse
The HTTP response instance.
value object
The object to serialize and send.
Returns
Task
A task representing the asynchronous operation.