This section shows all the different ways you capture input and examine request to your web application.
-
This exists on since .NET Core 1.0 however the configuration for the cookie has changed slightly. We are using
IAntiForgery
interface to store and generate anti forgery token to prevent XSRF/CSRF attacks. -
HTTP Verb (1)
-
Detect the verb/method of the current request.
-
-
Headers (3)
-
Enumerate all the available headers in a request.
-
Access Request Headers using common HTTP header names contained in HeaderNames
This sample shows all the common HTTP header names contained in
HeaderNames
class. So instead of using string to obtain a HTTP Header, you can just use a convenient constant such asHeaderNames.ContentType
. -
Type Safe Access to Request Headers
Instead of using string to access HTTP headers, use type safe object properties to access common HTTP headers.
-
-
Query String (5)
-
Access single value query string.
-
Access multiples values query string.
-
List all query string values. Also shows the implicat conversion from
StringValues
tostring
.
There are multiple ways to generate query strings.
-
Use
System.Net.Http.FormUrlEncodedContent
to generate URL encoded query string. -
Use
Microsoft.AspNetCore.Http.QueryString.Create
to generate URL encoded query string. -
More functionalities to generate and parse query string is available at Web Utilities section.
-
-
Form (2)
-
Handles the values submitted via a form.
-
Upload a single file and save it to the current directory (check out the usage of
.UseContentRoot(Directory.GetCurrentDirectory())
)
-
-
Cookies (2)
-
Read and write cookies.
-
Simply demonstrates on how to remove cookies.
-