src/packages/EmbedIO/HttpContextExtensions-Requests.cs
/// <summary>
/// Parses a request URL query. Note that this is different from getting the <see cref="IHttpRequest.QueryString"/> property,
/// in that fields without an equal sign are treated as if they have an empty value, instead of their keys being grouped
/// as values of the <c>null</c> key.
/// </summary>
/// <param name="this">The <see cref="IHttpContext"/> on which this method is called.</param>
/// <returns>A read-only <see cref="NameValueCollection"/>.</returns>
/// <exception cref="NullReferenceException"><paramref name="this"/> is <see langword="null"/>.</exception>
/// <remarks>
/// <para>This method may safely be called more than once for the same <see cref="IHttpContext"/>:
/// it will return the same collection instead of trying to parse the request body again.</para>
/// </remarks>
Parses a request URL query. Note that this is different from getting the  property,
in that fields without an equal sign are treated as if they have an empty value, instead of their keys being grouped
as values of the null
Parses a request URL query . Note that this is different from getting the property in that fields without an equal sign are treated as if they have an empty value instead of their keys being grouped as values of the null
public static NameValueCollection GetRequestQueryData(this IHttpContext @this)
        {
            if (!@this.Items.TryGetValue(QueryDataKey, out var previousResult))
            {
                NameValueCollection result;
                try
                {
                    result = UrlEncodedDataParser.Parse(@this.Request.Url.Query, false);
                }
                catch (Exception e)
                {
                    @this.Items[FormDataKey] = e;
                    throw;
                }
                @this.Items[FormDataKey] = result;
                return result;
            }
            return previousResult switch {
                NameValueCollection collection => collection,
                Exception exception => throw exception.RethrowPreservingStackTrace(),
                null => throw SelfCheck.Failure($"Previous result of {nameof(HttpContextExtensions)}.{nameof(GetRequestQueryData)} is null."),
                _ => throw SelfCheck.Failure($"Previous result of {nameof(HttpContextExtensions)}.{nameof(GetRequestQueryData)} is of unexpected type {previousResult.GetType().FullName}"),
            };
        }
public static NameValueCollection GetRequestQueryData ( this IHttpContext @this ) { if ( ! @this . Items . TryGetValue ( QueryDataKey , out var previousResult ) ) { NameValueCollection result ; try { result = UrlEncodedDataParser . Parse ( @this . Request . Url . Query , false ) ; } catch ( Exception e ) { @this . Items [ FormDataKey ] = e ; throw ; } @this . Items [ FormDataKey ] = result ; return result ; } return previousResult switch { NameValueCollection collection => collection , Exception exception => throw exception . RethrowPreservingStackTrace ( ) , null => throw SelfCheck . Failure ( $" Previous result of  { nameof ( HttpContextExtensions ) } . { nameof ( GetRequestQueryData ) }  is null. " ) , _ => throw SelfCheck . Failure ( $" Previous result of  { nameof ( HttpContextExtensions ) } . { nameof ( GetRequestQueryData ) }  is of unexpected type  { previousResult . GetType ( ) . FullName } " ) , } ; }
Parses a request URL query.
Parses a request URL query .
A read-only .
A read - only .
None
IHttpContext
this
this
The  on which this method is called.
The on which this method is called .
remarks
This method may safely be called more than once for the same :
it will return the same collection instead of trying to parse the request body again.
This method may safely be called more than once for the same : it will return the same collection instead of trying to parse the request body again .