Class RequestExtensions
- Namespace
- Dynamicweb.Environment
- Assembly
- Dynamicweb.Core.dll
Extension for IRequest that enables the return of strongly typed objects from the requests querystring or form.
public static class RequestExtensions
- Inheritance
-
RequestExtensions
- Inherited Members
Methods
GetBoolean(IRequest, string)
Gets the boolean representation of the value for the given key. The value is parsed using the relevant helper API, so default values for the type might be returned.
public static bool GetBoolean(this IRequest request, string key)
Parameters
Returns
- bool
The value of a valid boolean object (
key). In all other casesfalse.
GetClientIPAddress(IRequest)
Tries to resolve the client ip address for proxied request
public static string? GetClientIPAddress(this IRequest request)
Parameters
requestIRequestThe request.
Returns
- string
Client ip address, if possible, otherwise null
GetDate(IRequest, string)
Gets the date representation of the value for the given key. The value is parsed using the relevant helper API, so default values for the type might be returned.
public static DateTime GetDate(this IRequest request, string key)
Parameters
Returns
- DateTime
DateTime.
GetDouble(IRequest, string)
Gets the double representation of the value for the given key. The value is parsed using the relevant helper API, so default values for the type might be returned.
public static double GetDouble(this IRequest request, string key)
Parameters
Returns
- double
System.Double.
GetFiles(IRequest)
Tries to get posted files from the
public static PostedFileCollection GetFiles(this IRequest request)
Parameters
requestIRequest
Returns
GetInt32(IRequest, string)
Gets the integer representation of the value for the given key. The value is parsed using the relevant helper API, so default values for the type might be returned.
public static int GetInt32(this IRequest request, string key)
Parameters
Returns
- int
System.Int32.
GetInt64(IRequest, string)
Gets the long representation of the value for the given key. The value is parsed using the relevant helper API, so default values for the type might be returned.
public static long GetInt64(this IRequest request, string key)
Parameters
Returns
- long
System.Int64.
GetString(IRequest, string)
Gets the string representation of the value for the given key. The value is parsed using the relevant helper API, so default values for the type might be returned.
public static string GetString(this IRequest request, string key)
Parameters
Returns
- string
System.Int64.
HasRequest(IRequest, string)
Determines whether the specified key exists in the request.
public static bool HasRequest(this IRequest request, string key)
Parameters
Returns
- bool
trueif the specified key has request; otherwise,false.
TryGetBoolean(IRequest, string, out bool)
Tries to retrieve the boolean value associated with the specified key from querystring of the request.
public static bool TryGetBoolean(this IRequest request, string key, out bool value)
Parameters
requestIRequestThe request.
keystringThe key of the value to retrieve.
valueboolWhen this method returns, contains the boolean value associated with the specified key, if the key is found and the value can be parsed as a boolean; otherwise, the default value for the type.
Returns
- bool
trueif the key was found and the value was successfully retrieved and parsed as a boolean; otherwise,false.
TryGetDate(IRequest, string, out DateTime)
Tries to retrieve the date value associated with the specified key from the querystring of the request.
public static bool TryGetDate(this IRequest request, string key, out DateTime value)
Parameters
requestIRequestThe request.
keystringThe key of the value to retrieve.
valueDateTimeWhen this method returns, contains the date value associated with the specified key, if the key is found and the value can be parsed as a date; otherwise, the default value for the type.
Returns
- bool
trueif the key was found and the value was successfully retrieved and parsed as a date; otherwise,false.
TryGetDouble(IRequest, string, out double)
Tries to retrieve the double value associated with the specified key from querystring of the request.
public static bool TryGetDouble(this IRequest request, string key, out double value)
Parameters
requestIRequestThe request.
keystringThe key of the value to retrieve.
valuedoubleWhen this method returns, contains the double value associated with the specified key, if the key is found and the value can be parsed as a double; otherwise, the default value for the type.
Returns
- bool
trueif the key was found and the value was successfully retrieved and parsed as a double; otherwise,false.
TryGetInt32(IRequest, string, out int)
Tries to retrieve the integer value associated with the specified key from querystring of the request.
public static bool TryGetInt32(this IRequest request, string key, out int value)
Parameters
requestIRequestThe request.
keystringThe key of the value to retrieve.
valueintWhen this method returns, contains the integer value associated with the specified key, if the key is found and the value can be parsed as an integer; otherwise, the default value for the type.
Returns
- bool
trueif the key was found and the value was successfully retrieved and parsed as an integer; otherwise,false.
TryGetInt64(IRequest, string, out long)
Tries to retrieve the integer value associated with the specified key from querystring of the request.
public static bool TryGetInt64(this IRequest request, string key, out long value)
Parameters
requestIRequestThe request.
keystringThe key of the value to retrieve.
valuelongWhen this method returns, contains the integer value associated with the specified key, if the key is found and the value can be parsed as an integer; otherwise, the default value for the type.
Returns
- bool
trueif the key was found and the value was successfully retrieved and parsed as an integer; otherwise,false.
TryGetString(IRequest, string, out string?)
Tries to retrieve the value associated with the specified key from querystring of the request.
public static bool TryGetString(this IRequest request, string key, out string? value)
Parameters
requestIRequestThe collection to retrieve the value from.
keystringThe key of the value to retrieve.
valuestringWhen this method returns, contains the value associated with the specified key, if the key is found; otherwise,
null.
Returns
- bool
trueif the key was found and the value was successfully retrieved; otherwise,false.