Client
This contains methods and classes providing functionality for interacting with app's client-side and divided into two categories:
Client alerts
Classes and methods intended to help in communicating with client side by sending alerts and messages ti be displayed in UI
ClientAlert
ClientAlert class itself represents an alert of specified type with message. This is a main class of alerts infrastructure.
It has two properties:
Type
string
Type of alert. E.g. Success, Warning or Error.
Message
string
Message sending with alert.
ClientAlertProvider
ClientAlertProvider allows to perform alert-related operations, provides methods for assisting in transferring alerts from server side to client.
AddClientAlert
void
Adds alert to be transferred to client.
GetAllClientAlerts
IEnumerable<ClientAlert>
Gets all alerts transferred to client.
Action result
ClientAlertResult - represents an alert to be send along with action result.
Extension method for IActionResult:
AddClientAlert
void
Appends specified alert to IActionResult
Sample usage
Create IActionResult extensions:
Generate ClientAlert in server side:
Handle alerts in TagHelper:
Use ClientAlertsTagHelper in _Layout.cshtml to send ClientAlert to client side:
Client options
This is a group of methods and classes assisting in passing data represented by dictionary via HttpContext.Items.
ClientOptionProvider
It provides methods assisting in passing data represented by dictionary via HttpContext.Items:
AddClientOptions
void
Places set of options with specified key into current HttpContext.
GetClientOptions
IReadOnlyDictionary<string, object>
Gets all options with specified key stored in current HttpContext.
GetAllClientOptions
IReadOnlyDictionary<string, IReadOnlyDictionary<string, object>>
Gets all options stored in current HttpContext.
BuildClientOptionsKey
string
Builds a key for options using routeData and taking into account current area, controller and action methods. In such way all options will be related to their corresponding pages (urls).
Controller extensions
This controller extensions are helping in manipulating with options:
AddClientOptions
void
Adds client options to context associated with controller. There are different versions taking options as object with some public properties or options dictionary.
Sample usage
Generate ClientOption in server side:
Handle alerts in TagHelper:
Use ClientOptionsTagHelper in _Layout.cshtml to send ClientOption to client side:
Last updated
Was this helpful?