WebContextService¶
Implements IWebContextService for the web tier: resolves, creates, and persists web contexts by caching them in HttpContext.Session and proxying cache misses to the remote WCF IWebContextService endpoint.
Purpose¶
- Implements
IWebContextServicefor the web tier: resolves, creates, and persists web contexts by caching them inHttpContext.Sessionand proxying cache misses to the remote WCFIWebContextServiceendpoint. - Constructed once per request (
InstancePerRequestin Autofac) but reads/writes a session-scoped dictionary, so cached contexts survive across requests within the same session.
Context¶
- Namespace:
SAIF.Web - Assembly/package:
SAIF.Framework.Web.Mvc (source-shipping NuGet package) - Kind: class (service)
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| WebContextService(IEnvironmentService) | public WebContextService(IEnvironmentService environmentService) |
Initializes the session-backed context cache and resolves the cached WCF endpoint URL for the session; see the "Initialize the web context service for a session" operation. |
| Get() | public IWebContext Get() |
Creates a brand-new web context via the remote service and caches it; see the "Create a new web context" operation. |
| Get(string contextId) | public IWebContext Get(string contextId) |
Returns the session-cached context for the id, or recreates it remotely on a cache miss; see the "Get a web context by id" operation. |
| Get(string applicationName, string sessionId) | public IWebContext Get(string applicationName, string sessionId) |
Always fetches the context for the given application/session from the remote service and refreshes the session cache; see the "Get a web context by application and session" operation. |
| Save(string applicationName, string sessionId, IWebContext context) | public void Save(string applicationName, string sessionId, IWebContext context) |
Persists a context to the remote service without touching the session cache; used during cross-application navigation. |
Behavioral notes¶
- The remote WCF channel is opened and disposed per call (
using (var client = new WebContextServiceClient(serviceUrl))), so a call never leaves an open channel behind.
Constraints and usage notes¶
- Requires the
webContextServiceUrlenvironment setting to be resolvable in the current session; a missing value surfaces as a WCF endpoint construction failure on first use, not at construction time.
Sources¶
src/Web/WebContextService.cs