Skip to content

DefaultRequestContext class

namespace: Serenity.Services   assembly: Serenity.Net.Services

Default implementation for a IRequestContext.

public class DefaultRequestContext : IHasHandlerSettings, IRequestContext
parameter description
behaviors Behavior provider
cache Two level cache
localizer Text localizer
permissions Permissions
userAccessor User access
handlerSettings Request handler settings

Public Members

name description
DefaultRequestContext(…) Default implementation for a IRequestContext.
Behaviors { get; }
Cache { get; }
HandlerSettings { get; }
Localizer { get; }
Permissions { get; }
User { get; }

Exceptions

exception condition
ArgumentNullException Any of the arguments is null.

Remarks

This implementation is registered as a singleton by default, so it assumes its dependencies (e.g. IUserAccessor, IPermissionService, ITextLocalizer) are also registered as singletons. The default IUserAccessor implementation in web applications reads the current user from the ambient HTTP context, so a singleton is safe in that case.

If you need scoped implementations of any of these dependencies, register your own IRequestContext implementation and resolve them on demand from ServiceProvider (which returns the current request's scoped provider in web applications, and the root provider otherwise) instead of capturing them in the constructor.

See Also