public void ProcessInfo(IncludeInfoStrategy strategy, AbstractInfo info) { if (!strategy.IncludeInfoStrategyForLocationInfo.Include) { return; } var locationInfo = new LocationInfo() { AppDomainName = AppDomain.CurrentDomain.FriendlyName, ManagedThreadId = Thread.CurrentThread.ManagedThreadId, }; StackTrace strackTrace = new StackTrace(); StackFrame[] stackFrames = strackTrace.GetFrames(); int skip = 1; for (int i = 0; i < stackFrames.Length; i++) { if (stackFrames[i].GetMethod().ReflectedType != null && stackFrames[i].GetMethod().ReflectedType.Assembly.FullName.Contains("Adhesive.AppInfoCenter")) { skip++; } } if (stackFrames.Length >= skip) { StackFrame stackFrame = stackFrames[skip]; if (stackFrame != null) { var methodBase = stackFrame.GetMethod(); if (methodBase != null) { locationInfo.AssemblyName = methodBase.Module.Assembly.ToString(); locationInfo.ModuleName = methodBase.Module.ToString(); locationInfo.TypeName = methodBase.ReflectedType.ToString(); locationInfo.MethodName = methodBase.ToString(); } } StackTrace skipped = new StackTrace(skip, true); if (skipped != null) { if (strategy.IncludeInfoStrategyForLocationInfo.IncludeStackTrace) { locationInfo.StackTrace = skipped.ToString(); } else { locationInfo.StackTrace = string.Empty; } } } info.LocationInfo = locationInfo; }
public void ProcessInfo(IncludeInfoStrategy strategy, AbstractInfo info) { if (info.ContextIdentity == null) { if (HttpContext.Current != null && HttpContext.Current.Items != null) { if (HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextIdentityKey] == null) { HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextIdentityKey] = Guid.NewGuid().ToString(); } info.ContextIdentity = HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextIdentityKey].ToString(); } else { if (CallContext.GetData(AppInfoCenterConfiguration.Const.ContextIdentityKey) == null) { CallContext.SetData(AppInfoCenterConfiguration.Const.ContextIdentityKey, Guid.NewGuid().ToString()); } info.ContextIdentity = CallContext.GetData(AppInfoCenterConfiguration.Const.ContextIdentityKey).ToString(); } } if (string.IsNullOrEmpty(info.ModuleName)) { info.ModuleName = DefaultModuleName; } if (string.IsNullOrEmpty(info.CategoryName) && info.ModuleName == DefaultModuleName) { if (HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Request.Url != null && HttpContext.Current.Request.Url.AbsolutePath != null) { info.CategoryName = HttpContext.Current.Request.Url.AbsolutePath.ToLower(); } else if (info.LocationInfo != null && !string.IsNullOrEmpty(info.LocationInfo.TypeName)) { info.CategoryName = info.LocationInfo.TypeName; } } if (HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Request.Url != null && HttpContext.Current.Request.Url.Host != null) { info.DomainName = HttpContext.Current.Request.Url.Host; } }
public void ProcessInfo(IncludeInfoStrategy strategy, AbstractInfo info) { if (!strategy.IncludeInfoStrategyForLocationInfo.Include) return; var locationInfo = new LocationInfo() { AppDomainName = AppDomain.CurrentDomain.FriendlyName, ManagedThreadId = Thread.CurrentThread.ManagedThreadId, }; StackTrace strackTrace = new StackTrace(); StackFrame[] stackFrames = strackTrace.GetFrames(); int skip = 1; for (int i = 0; i < stackFrames.Length; i++) { if (stackFrames[i].GetMethod().ReflectedType != null && stackFrames[i].GetMethod().ReflectedType.Assembly.FullName.Contains("Adhesive.AppInfoCenter")) { skip++; } } if (stackFrames.Length >= skip) { StackFrame stackFrame = stackFrames[skip]; if (stackFrame != null) { var methodBase = stackFrame.GetMethod(); if (methodBase != null) { locationInfo.AssemblyName = methodBase.Module.Assembly.ToString(); locationInfo.ModuleName = methodBase.Module.ToString(); locationInfo.TypeName = methodBase.ReflectedType.ToString(); locationInfo.MethodName = methodBase.ToString(); } } StackTrace skipped = new StackTrace(skip, true); if (skipped != null) { if (strategy.IncludeInfoStrategyForLocationInfo.IncludeStackTrace) locationInfo.StackTrace = skipped.ToString(); else locationInfo.StackTrace = string.Empty; } } info.LocationInfo = locationInfo; }
public void ProcessInfo(IncludeInfoStrategy strategy, AbstractInfo info) { if (info.ContextIdentity == null) { if (HttpContext.Current != null && HttpContext.Current.Items != null) { if (HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextIdentityKey] == null) HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextIdentityKey] = Guid.NewGuid().ToString(); info.ContextIdentity = HttpContext.Current.Items[AppInfoCenterConfiguration.Const.ContextIdentityKey].ToString(); } else { if (CallContext.GetData(AppInfoCenterConfiguration.Const.ContextIdentityKey) == null) CallContext.SetData(AppInfoCenterConfiguration.Const.ContextIdentityKey, Guid.NewGuid().ToString()); info.ContextIdentity = CallContext.GetData(AppInfoCenterConfiguration.Const.ContextIdentityKey).ToString(); } } if (string.IsNullOrEmpty(info.ModuleName)) { info.ModuleName = DefaultModuleName; } if (string.IsNullOrEmpty(info.CategoryName) && info.ModuleName == DefaultModuleName) { if (HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Request.Url != null && HttpContext.Current.Request.Url.AbsolutePath != null) { info.CategoryName = HttpContext.Current.Request.Url.AbsolutePath.ToLower(); } else if (info.LocationInfo != null && !string.IsNullOrEmpty(info.LocationInfo.TypeName)) { info.CategoryName = info.LocationInfo.TypeName; } } if (HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Request.Url != null && HttpContext.Current.Request.Url.Host != null) info.DomainName = HttpContext.Current.Request.Url.Host; }
public void ProcessInfo(IncludeInfoStrategy strategy, AbstractInfo info) { if (!strategy.IncludeInfoStrategyForEnvironmentInfo.Include) return; if (environmentInfo == null) { environmentInfo = new EnvironmentInfo() { CurrentDirectory = Environment.CurrentDirectory, MachineName = Environment.MachineName, OperatingSystem = Environment.OSVersion.ToString(), //ProcessId = Process.GetCurrentProcess().Id, //ProcessName = Process.GetCurrentProcess().ProcessName, UserInteractive = Environment.UserInteractive, UserDomainName = Environment.UserDomainName, UserName = Environment.UserName, Version = Environment.Version.ToString(), }; } info.EnvironmentInfo = environmentInfo; }
public void ProcessInfo(IncludeInfoStrategy strategy, AbstractInfo info) { if (!strategy.IncludeInfoStrategyForEnvironmentInfo.Include) { return; } if (environmentInfo == null) { environmentInfo = new EnvironmentInfo() { CurrentDirectory = Environment.CurrentDirectory, MachineName = Environment.MachineName, OperatingSystem = Environment.OSVersion.ToString(), //ProcessId = Process.GetCurrentProcess().Id, //ProcessName = Process.GetCurrentProcess().ProcessName, UserInteractive = Environment.UserInteractive, UserDomainName = Environment.UserDomainName, UserName = Environment.UserName, Version = Environment.Version.ToString(), }; } info.EnvironmentInfo = environmentInfo; }
public void ProcessInfo(IncludeInfoStrategy strategy, AbstractInfo info) { if (!strategy.IncludeInfoStrategyForHttpContextInfo.Include) return; try { var httpContext = HttpContext.Current; if (httpContext != null) { var httpContextInfo = new HttpContextInfo() { Handler = httpContext.Handler == null ? "" : httpContext.Handler.GetType().FullName, IsCustomErrorEnabled = httpContext.IsCustomErrorEnabled, IsDebuggingEnabled = httpContext.IsDebuggingEnabled, SkipAuthorization = httpContext.SkipAuthorization, }; try { if (httpContext.Session != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeHttpContextSessions) { var session = new Dictionary<string, string>(); foreach (var key in httpContext.Session.Keys) { if (!session.ContainsKey(key.ToString())) session.Add(key.ToString(), httpContext.Session[key.ToString()] == null ? "" : httpContext.Session[key.ToString()].ToString()); } httpContextInfo.Sessions = session; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Session" + ex.ToString()); } try { if (httpContext.Items != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeHttpContextItems) { var items = new Dictionary<string, string>(); foreach (var key in httpContext.Items.Keys) { if (!items.ContainsKey(key.ToString())) items.Add(key.ToString(), httpContext.Items[key] == null ? "" : httpContext.Items[key].ToString()); } httpContextInfo.Items = items; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Items" + ex.ToString()); } try { var request = httpContext.Request; if (request != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForRequestInfo.Include) { var requestInfo = strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForRequestInfo.IncludeBasicInfo ? new RequestInfo() { AcceptTypes = request.AcceptTypes == null ? "" : string.Join(",", request.AcceptTypes), AnonymousID = request.AnonymousID, ApplicationPath = request.ApplicationPath, AppRelativeCurrentExecutionFilePath = request.AppRelativeCurrentExecutionFilePath, Browser = request.Browser == null ? "" : request.Browser.ToString(), ContentEncoding = request.ContentEncoding == null ? "" : request.ContentEncoding.ToString(), ContentLength = request.ContentLength, ContentType = request.ContentType, CurrentExecutionFilePath = request.CurrentExecutionFilePath, FilePath = request.FilePath, HttpMethod = request.HttpMethod, IsAuthenticated = request.IsAuthenticated, IsLocal = request.IsLocal, IsSecureConnection = request.IsSecureConnection, LogonUserIdentity = request.LogonUserIdentity == null ? "" : request.LogonUserIdentity.ToString(), Path = request.Path, PathInfo = request.PathInfo, PhysicalApplicationPath = request.PhysicalApplicationPath, PhysicalPath = request.PhysicalPath, Url = request.Url == null ? "" : request.Url.ToString(), UrlReferrer = request.UrlReferrer == null ? "" : request.UrlReferrer.ToString(), RequestType = request.RequestType, UserAgent = request.UserAgent, UserHostAddress = request.UserHostAddress, UserHostName = request.UserHostName, UserLanguages = request.UserLanguages == null ? "" : string.Join(",", request.UserLanguages), } : new RequestInfo(); try { if (request.Cookies != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForRequestInfo.IncludeRequestCookies) { var cookies = new Dictionary<string, string>(); foreach (var key in request.Cookies.Keys) { if (!cookies.ContainsKey(key.ToString())) cookies.Add(key.ToString(), request.Cookies[key.ToString()] == null ? "" : request.Cookies[key.ToString()].ToString()); } requestInfo.Cookies = cookies; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Request.Cookies" + ex.ToString()); } try { if (request.Form != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForRequestInfo.IncludeRequestForms) { var form = new Dictionary<string, string>(); foreach (var key in request.Form.Keys) { if (!form.ContainsKey(key.ToString())) form.Add(key.ToString(), request.Form[key.ToString()] == null ? "" : request.Form[key.ToString()].ToString()); } requestInfo.Forms = form; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Request.Form" + ex.ToString()); } try { if (request.Headers != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForRequestInfo.IncludeRequestHeaders) { var headers = new Dictionary<string, string>(); foreach (var key in request.Headers.Keys) { if (!headers.ContainsKey(key.ToString())) headers.Add(key.ToString(), request.Headers[key.ToString()] == null ? "" : request.Headers[key.ToString()].ToString()); } requestInfo.Headers = headers; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Request.Headers" + ex.ToString()); } try { if (request.QueryString != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForRequestInfo.IncludeRequestQueryStrings) { var querystring = new Dictionary<string, string>(); foreach (var key in request.QueryString.Keys) { if (!querystring.ContainsKey(key.ToString())) querystring.Add(key.ToString(), request.QueryString[key.ToString()] == null ? "" : request.QueryString[key.ToString()].ToString()); } requestInfo.QueryStrings = querystring; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Request.QueryString" + ex.ToString()); } httpContextInfo.RequestInfo = requestInfo; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Request" + ex.ToString()); } try { var response = httpContext.Response; if (response != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForResponseInfo.Include) { var responseInfo = strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForResponseInfo.IncludeBasicInfo ? new ResponseInfo() { CacheControl = response.CacheControl, Charset = response.Charset, ContentEncoding = response.ContentEncoding == null ? "" : response.ContentEncoding.ToString(), ContentType = response.ContentType, ExpiresAbsolute = response.ExpiresAbsolute, HeaderEncoding = response.HeaderEncoding == null ? "" : response.HeaderEncoding.ToString(), IsClientConnected = response.IsClientConnected, IsRequestBeingRedirected = response.IsRequestBeingRedirected, RedirectLocation = response.RedirectLocation, Status = response.Status, StatusCode = response.StatusCode, StatusDescription = response.StatusDescription, SuppressContent = response.SuppressContent, TrySkipIisCustomErrors = response.TrySkipIisCustomErrors, } : new ResponseInfo(); try { if (response.Cookies != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForResponseInfo.IncludeResponseCookies) { var cookies = new Dictionary<string, string>(); foreach (var key in response.Cookies.Keys) { if (!cookies.ContainsKey(key.ToString())) cookies.Add(key.ToString(), response.Cookies[key.ToString()] == null ? "" : response.Cookies[key.ToString()].ToString()); } responseInfo.Cookies = cookies; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Response.Cookies" + ex.ToString()); } httpContextInfo.ResponseInfo = responseInfo; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Response" + ex.ToString()); } info.HttpContextInfo = httpContextInfo; } } catch (Exception ex) { LocalLoggingService.Error("httpContext" + ex.ToString()); } }
public void ProcessInfo(IncludeInfoStrategy strategy, AbstractInfo info) { if (!strategy.IncludeInfoStrategyForMvcContextInfo.Include) return; var httpContext = HttpContext.Current; if (httpContext != null) { var mvcContextInfo = new MvcContextInfo(); ControllerContext controllerContext = null; var isMvcApp = false; var actionExecutedContext = httpContext.Items[AppInfoCenterConfiguration.Const.ControllerContextIdentityKey] as ActionExecutedContext; if (actionExecutedContext != null) { isMvcApp = true; mvcContextInfo.ControllerName = actionExecutedContext.ActionDescriptor.ControllerDescriptor.ControllerName; mvcContextInfo.ActionName = actionExecutedContext.ActionDescriptor.ActionName; if (actionExecutedContext.Result != null) mvcContextInfo.ActionResultType = actionExecutedContext.Result.ToString(); if (actionExecutedContext.Controller != null) controllerContext = actionExecutedContext.Controller.ControllerContext; mvcContextInfo.State = MvcActionStage.ActionExecuted; } var actionExecutingContext = httpContext.Items[AppInfoCenterConfiguration.Const.ControllerContextIdentityKey] as ActionExecutingContext; if (actionExecutingContext != null) { isMvcApp = true; if (strategy.IncludeInfoStrategyForMvcContextInfo.IncludeParameterData) { var parameterData = new Dictionary<string, string>(); foreach (var key in actionExecutingContext.ActionParameters.Keys) { parameterData.Add(key, (actionExecutingContext.ActionParameters[key] ?? "").ToString()); } mvcContextInfo.ParameterData = parameterData; } mvcContextInfo.ControllerName = actionExecutingContext.ActionDescriptor.ControllerDescriptor.ControllerName; mvcContextInfo.ActionName = actionExecutingContext.ActionDescriptor.ActionName; if (actionExecutingContext.Result != null) mvcContextInfo.ActionResultType = actionExecutingContext.Result.ToString(); if (actionExecutingContext.Controller != null) controllerContext = actionExecutingContext.Controller.ControllerContext; mvcContextInfo.State = MvcActionStage.ActionExecuting; } var resultExecutedContext = httpContext.Items[AppInfoCenterConfiguration.Const.ControllerContextIdentityKey] as ResultExecutedContext; if (resultExecutedContext != null) { isMvcApp = true; if (resultExecutedContext.Result != null) mvcContextInfo.ActionResultType = resultExecutedContext.Result.ToString(); if (resultExecutedContext.Controller != null) controllerContext = resultExecutedContext.Controller.ControllerContext; mvcContextInfo.State = MvcActionStage.ResultExecuted; } var resultExecutingContext = httpContext.Items[AppInfoCenterConfiguration.Const.ControllerContextIdentityKey] as ResultExecutingContext; if (resultExecutingContext != null) { isMvcApp = true; if (actionExecutedContext.Result != null) mvcContextInfo.ActionResultType = resultExecutingContext.Result.ToString(); if (resultExecutingContext.Controller != null) controllerContext = resultExecutingContext.Controller.ControllerContext; mvcContextInfo.State = MvcActionStage.ResultExecuting; } if (controllerContext != null) { mvcContextInfo.IsChildAction = controllerContext.IsChildAction; if (strategy.IncludeInfoStrategyForMvcContextInfo.IncludeViewData) { var viewData = new Dictionary<string, string>(); foreach (var key in controllerContext.Controller.ViewData.Keys) { viewData.Add(key, (controllerContext.Controller.ViewData[key] ?? "").ToString()); } mvcContextInfo.ViewData = viewData; } if (strategy.IncludeInfoStrategyForMvcContextInfo.IncludeRouteData) { var routeData = new Dictionary<string, string>(); foreach (var key in controllerContext.RouteData.Values.Keys) { routeData.Add(key, (controllerContext.RouteData.Values[key] ?? "").ToString()); } mvcContextInfo.RouteData = routeData; } if (strategy.IncludeInfoStrategyForMvcContextInfo.IncludeTempData) { var tempData = new Dictionary<string, string>(); foreach (var key in controllerContext.Controller.TempData.Keys) { tempData.Add(key, (controllerContext.Controller.TempData[key] ?? "").ToString()); } mvcContextInfo.TempData = tempData; } } if (isMvcApp) info.MvcContextInfo = mvcContextInfo; } }
public void ProcessInfo(IncludeInfoStrategy strategy, AbstractInfo info) { if (!strategy.IncludeInfoStrategyForHttpContextInfo.Include) { return; } try { var httpContext = HttpContext.Current; if (httpContext != null) { var httpContextInfo = new HttpContextInfo() { Handler = httpContext.Handler == null ? "" : httpContext.Handler.GetType().FullName, IsCustomErrorEnabled = httpContext.IsCustomErrorEnabled, IsDebuggingEnabled = httpContext.IsDebuggingEnabled, SkipAuthorization = httpContext.SkipAuthorization, }; try { if (httpContext.Session != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeHttpContextSessions) { var session = new Dictionary <string, string>(); foreach (var key in httpContext.Session.Keys) { if (!session.ContainsKey(key.ToString())) { session.Add(key.ToString(), httpContext.Session[key.ToString()] == null ? "" : httpContext.Session[key.ToString()].ToString()); } } httpContextInfo.Sessions = session; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Session" + ex.ToString()); } try { if (httpContext.Items != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeHttpContextItems) { var items = new Dictionary <string, string>(); foreach (var key in httpContext.Items.Keys) { if (!items.ContainsKey(key.ToString())) { items.Add(key.ToString(), httpContext.Items[key] == null ? "" : httpContext.Items[key].ToString()); } } httpContextInfo.Items = items; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Items" + ex.ToString()); } try { var request = httpContext.Request; if (request != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForRequestInfo.Include) { var requestInfo = strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForRequestInfo.IncludeBasicInfo ? new RequestInfo() { AcceptTypes = request.AcceptTypes == null ? "" : string.Join(",", request.AcceptTypes), AnonymousID = request.AnonymousID, ApplicationPath = request.ApplicationPath, AppRelativeCurrentExecutionFilePath = request.AppRelativeCurrentExecutionFilePath, Browser = request.Browser == null ? "" : request.Browser.ToString(), ContentEncoding = request.ContentEncoding == null ? "" : request.ContentEncoding.ToString(), ContentLength = request.ContentLength, ContentType = request.ContentType, CurrentExecutionFilePath = request.CurrentExecutionFilePath, FilePath = request.FilePath, HttpMethod = request.HttpMethod, IsAuthenticated = request.IsAuthenticated, IsLocal = request.IsLocal, IsSecureConnection = request.IsSecureConnection, LogonUserIdentity = request.LogonUserIdentity == null ? "" : request.LogonUserIdentity.ToString(), Path = request.Path, PathInfo = request.PathInfo, PhysicalApplicationPath = request.PhysicalApplicationPath, PhysicalPath = request.PhysicalPath, Url = request.Url == null ? "" : request.Url.ToString(), UrlReferrer = request.UrlReferrer == null ? "" : request.UrlReferrer.ToString(), RequestType = request.RequestType, UserAgent = request.UserAgent, UserHostAddress = request.UserHostAddress, UserHostName = request.UserHostName, UserLanguages = request.UserLanguages == null ? "" : string.Join(",", request.UserLanguages), } : new RequestInfo(); try { if (request.Cookies != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForRequestInfo.IncludeRequestCookies) { var cookies = new Dictionary <string, string>(); foreach (var key in request.Cookies.Keys) { if (!cookies.ContainsKey(key.ToString())) { cookies.Add(key.ToString(), request.Cookies[key.ToString()] == null ? "" : request.Cookies[key.ToString()].ToString()); } } requestInfo.Cookies = cookies; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Request.Cookies" + ex.ToString()); } try { if (request.Form != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForRequestInfo.IncludeRequestForms) { var form = new Dictionary <string, string>(); foreach (var key in request.Form.Keys) { if (!form.ContainsKey(key.ToString())) { form.Add(key.ToString(), request.Form[key.ToString()] == null ? "" : request.Form[key.ToString()].ToString()); } } requestInfo.Forms = form; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Request.Form" + ex.ToString()); } try { if (request.Headers != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForRequestInfo.IncludeRequestHeaders) { var headers = new Dictionary <string, string>(); foreach (var key in request.Headers.Keys) { if (!headers.ContainsKey(key.ToString())) { headers.Add(key.ToString(), request.Headers[key.ToString()] == null ? "" : request.Headers[key.ToString()].ToString()); } } requestInfo.Headers = headers; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Request.Headers" + ex.ToString()); } try { if (request.QueryString != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForRequestInfo.IncludeRequestQueryStrings) { var querystring = new Dictionary <string, string>(); foreach (var key in request.QueryString.Keys) { if (!querystring.ContainsKey(key.ToString())) { querystring.Add(key.ToString(), request.QueryString[key.ToString()] == null ? "" : request.QueryString[key.ToString()].ToString()); } } requestInfo.QueryStrings = querystring; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Request.QueryString" + ex.ToString()); } httpContextInfo.RequestInfo = requestInfo; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Request" + ex.ToString()); } try { var response = httpContext.Response; if (response != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForResponseInfo.Include) { var responseInfo = strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForResponseInfo.IncludeBasicInfo ? new ResponseInfo() { CacheControl = response.CacheControl, Charset = response.Charset, ContentEncoding = response.ContentEncoding == null ? "" : response.ContentEncoding.ToString(), ContentType = response.ContentType, ExpiresAbsolute = response.ExpiresAbsolute, HeaderEncoding = response.HeaderEncoding == null ? "" : response.HeaderEncoding.ToString(), IsClientConnected = response.IsClientConnected, IsRequestBeingRedirected = response.IsRequestBeingRedirected, RedirectLocation = response.RedirectLocation, Status = response.Status, StatusCode = response.StatusCode, StatusDescription = response.StatusDescription, SuppressContent = response.SuppressContent, TrySkipIisCustomErrors = response.TrySkipIisCustomErrors, } : new ResponseInfo(); try { if (response.Cookies != null && strategy.IncludeInfoStrategyForHttpContextInfo.IncludeInfoStrategyForResponseInfo.IncludeResponseCookies) { var cookies = new Dictionary <string, string>(); foreach (var key in response.Cookies.Keys) { if (!cookies.ContainsKey(key.ToString())) { cookies.Add(key.ToString(), response.Cookies[key.ToString()] == null ? "" : response.Cookies[key.ToString()].ToString()); } } responseInfo.Cookies = cookies; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Response.Cookies" + ex.ToString()); } httpContextInfo.ResponseInfo = responseInfo; } } catch (Exception ex) { LocalLoggingService.Error("httpContext.Response" + ex.ToString()); } info.HttpContextInfo = httpContextInfo; } } catch (Exception ex) { LocalLoggingService.Error("httpContext" + ex.ToString()); } }