Appearance
TryGetItem Method
Definition
- Namespace:
JASE.Extensions - Assembly:
JASE.Web.dll
bool TryGetItem(HttpContext context, string key, out T result)
csharp
bool TryGetItem(HttpContext context, string key, out T result)Attempts to retrieve a value from Items and cast it to the requested type.
Type parameters
| Name | Description |
|---|---|
T | The expected type of the item value. |
Parameters
| Name | Description |
|---|---|
context | The current HTTP context whose Items collection will be searched. |
key | The item key to look up. |
result | When this method returns , contains the value associated with key cast to T. Otherwise, contains the default value for T. |
Returns
if an item with the specified key exists and can be cast to T; otherwise, .
Remarks
This method does not throw if the key is missing or if the stored value is not of the requested type. In those cases, it returns and sets result to the default value.