Skip to content

WebEnvironmentService

WebEnvironmentService is the host-specific EnvironmentServiceBase implementation for ASP.NET web-application contexts. It resolves environment details using HttpContext.Current and implements IWebEnvironmentService as a minimal web-context surface.

Purpose

  • Supply web-application-specific environment resolution (host, client-external/inside-firewall status, local-machine status, and the current HttpContext.Current.User principal).

Context

  • Namespace: SAIF.Framework.Security
  • Assembly/package: SAIF.Framework.Security.EnvironmentApi

Public members

Member Signature Purpose
WebEnvironmentService() public WebEnvironmentService() Constructs the service and initializes ApplicationId/_defaultDirectory from HttpContext.Current.
WebEnvironmentService(sections) public WebEnvironmentService(params string[] sections) Constructs the service with specified configuration sections to load, initialized from HttpContext.Current.
MachineName override string MachineName { get; } Returns Environment.MachineName.
ApplicationHost override string ApplicationHost { get; } Returns a dev-host fallback (entdev03 via GetHostFromAppConfig()) when IsDeveloperMachine is true, the local machine name when IsLocalMachine is true, otherwise EnvironmentHost.ResolveHost() against the current request URL.
IsClientExternal override bool IsClientExternal { get; } true unless the client's UserHostAddress starts with one of the internalAddressRoots config setting's IP prefixes.
IsClientInsideFirewall override bool IsClientInsideFirewall { get; } true when the client's UserHostAddress starts with one of the insideFirewallAddressRoots config setting's IP prefixes.
IsLocalMachine override bool IsLocalMachine { get; } true when the current request URL IsLoopback (e.g., http://localhost/...).
IsWeb override bool IsWeb { get; } Always true.
User override IPrincipal User { get; } Returns HttpContext.Current.User.

Inherited public members

Members in this section are inherited from EnvironmentServiceBase in SAIF.Framework.Security.EnvironmentApi. They are available on this type through inheritance.

Member Signature Purpose Origin
GetConfigSetting string GetConfigSetting(string configKey) Retrieves a plain-text configuration value SAIF.Framework.Security.EnvironmentApi — EnvironmentServiceBase
GetConfigSetting\<T> T GetConfigSetting<T>(string configKey) Retrieves a typed configuration value SAIF.Framework.Security.EnvironmentApi — EnvironmentServiceBase
GetSecureConfigSetting string GetSecureConfigSetting(string configKey, string systemHashValue) Retrieves an encrypted configuration value SAIF.Framework.Security.EnvironmentApi — EnvironmentServiceBase
GetApplicationEnvironment ApplicationEnvironment GetApplicationEnvironment() Returns the current deployment tier SAIF.Framework.Security.EnvironmentApi — EnvironmentServiceBase
GetApplicationTrack string GetApplicationTrack() Returns the current application's deployment track SAIF.Framework.Security.EnvironmentApi — EnvironmentServiceBase
IsDeveloperMachine virtual bool IsDeveloperMachine { get; } Determines developer-machine status SAIF.Framework.Security.EnvironmentApi — EnvironmentServiceBase
Configurations ConfigurationSettings Configurations { get; } The current in-memory cached configuration settings SAIF.Framework.Security.EnvironmentApi — EnvironmentServiceBase

Behavioral notes

  • The private properties InternalAddressRoots and InsideFirewallAddressRoots read the internalAddressRoots and insideFirewallAddressRoots configuration settings respectively, splitting comma-separated IP prefix lists.
  • ApplicationHost resolution order mirrors the same developer/local/remote fallback pattern used by WcfEnvironmentService*.

Constraints and usage notes

  • Requires an active HttpContext.Current (ASP.NET request context); not suitable for non-web hosting contexts.
  • Also implements IWebEnvironmentService, exposing the same members as a narrower, web-specific interface for consumers that do not need the full IEnvironmentService surface.

Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.

Sources

  • SAIF.Framework.Security.EnvironmentApi\Services.Common\WebEnvironmentService.cs
  • SAIF.Framework.Security.EnvironmentApi\Services.Common\IWebEnvironmentService.cs
  • SAIF.Framework.Security.EnvironmentApi\Services.Common\EnvironmentServiceBase.cs