当前位置: 首页>>代码示例>>C#>>正文


C# HttpContext.GetRequest方法代码示例

本文整理汇总了C#中System.Web.HttpContext.GetRequest方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContext.GetRequest方法的具体用法?C# HttpContext.GetRequest怎么用?C# HttpContext.GetRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpContext的用法示例。


在下文中一共展示了HttpContext.GetRequest方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnInitializeTelemetry

        /// <summary>
        /// Implements initialization logic.
        /// </summary>
        /// <param name="platformContext">Http context.</param>
        /// <param name="requestTelemetry">Request telemetry object associated with the current request.</param>
        /// <param name="telemetry">Telemetry item to initialize.</param>
        protected override void OnInitializeTelemetry(HttpContext platformContext, RequestTelemetry requestTelemetry, ITelemetry telemetry)
        {
            if (platformContext != null)
            {
                var request = platformContext.GetRequest();

                if (request != null)
                {
                    foreach (var pattern in this.filterPatterns)
                    {
                        if (pattern.RegularExpression != null && request.UserAgent != null)
                        {
                            var match = pattern.RegularExpression.Match(request.UserAgent);
                            if (match.Success)
                            {
                                if (string.IsNullOrEmpty(telemetry.Context.Operation.SyntheticSource))
                                {
                                    telemetry.Context.Operation.SyntheticSource = !string.IsNullOrWhiteSpace(pattern.SourceName) ? pattern.SourceName : match.Value;
                                    return;
                                }
                            }
                        }
                    }
                }
            }
        }
开发者ID:jawn,项目名称:ApplicationInsights-server-dotnet,代码行数:32,代码来源:SyntheticUserAgentTelemetryInitializer.cs

示例2: OnInitializeTelemetry

        /// <summary>
        /// Implements initialization logic.
        /// </summary>
        /// <param name="platformContext">Http context.</param>
        /// <param name="requestTelemetry">Request telemetry object associated with the current request.</param>
        /// <param name="telemetry">Telemetry item to initialize.</param>
        protected override void OnInitializeTelemetry(HttpContext platformContext, RequestTelemetry requestTelemetry, ITelemetry telemetry)
        {
            if (string.IsNullOrEmpty(telemetry.Context.Operation.SyntheticSource))
            {
                if (platformContext != null)
                {
                    var request = platformContext.GetRequest();

                    if (request != null && !string.IsNullOrEmpty(request.UserAgent))
                    {
                        // We expect customers to configure telemetry initializer before they add it to active configuration
                        // So we will not protect fiterPatterns array with locks (to improve perf)
                        foreach (string pattern in this.filterPatterns)
                        {
                            if (!string.IsNullOrWhiteSpace(pattern) &&
                                request.UserAgent.IndexOf(pattern, StringComparison.OrdinalIgnoreCase) != -1)
                            {
                                telemetry.Context.Operation.SyntheticSource = "Bot";
                                return;
                            }
                        }
                    }
                }
            }
        }
开发者ID:Microsoft,项目名称:ApplicationInsights-dotnet-server,代码行数:31,代码来源:SyntheticUserAgentTelemetryInitializer.cs

示例3: OnInitializeTelemetry

        /// <summary>
        /// Implements initialization logic.
        /// </summary>
        /// <param name="platformContext">Http context.</param>
        /// <param name="requestTelemetry">Request telemetry object associated with the current request.</param>
        /// <param name="telemetry">Telemetry item to initialize.</param>
        protected override void OnInitializeTelemetry(
            HttpContext platformContext,
            RequestTelemetry requestTelemetry,
            ITelemetry telemetry)
        {
            if (string.IsNullOrEmpty(telemetry.Context.Operation.SyntheticSource))
            {
                // platformContext and request != null checks are in the base class
                var request = platformContext.GetRequest();

                var runIdHeader = request.UnvalidatedGetHeader(TestRunHeader);
                var locationHeader = request.UnvalidatedGetHeader(TestLocationHeader);

                if (!string.IsNullOrEmpty(runIdHeader) &&
                    !string.IsNullOrEmpty(locationHeader))
                {
                    telemetry.Context.Operation.SyntheticSource = GsmSource;

                    // User id will be Pop location name and RunId (We cannot use just location because of sampling)
                    telemetry.Context.User.Id = locationHeader + "_" + runIdHeader;
                    telemetry.Context.Session.Id = runIdHeader;
                }
            }
        }
开发者ID:Microsoft,项目名称:ApplicationInsights-dotnet-server,代码行数:30,代码来源:WebTestTelemetryInitializer.cs

示例4: OnInitializeTelemetry

        /// <summary>
        /// Implements initialization logic.
        /// </summary>
        /// <param name="platformContext">Http context.</param>
        /// <param name="requestTelemetry">Request telemetry object associated with the current request.</param>
        /// <param name="telemetry">Telemetry item to initialize.</param>
        protected override void OnInitializeTelemetry(
            HttpContext platformContext,
            RequestTelemetry requestTelemetry,
            ITelemetry telemetry)
        {
            if (platformContext != null)
            {
                var request = platformContext.GetRequest();
                if (request != null)
                {
                    foreach (var filter in this.filters)
                    {
                        var filterHeader = request.UnvalidatedGetHeader(filter.FilterHeader);
                        if (!string.IsNullOrEmpty(filterHeader))
                        {
                            if (string.IsNullOrEmpty(telemetry.Context.Operation.SyntheticSource))
                            {
                                telemetry.Context.Operation.SyntheticSource = !string.IsNullOrEmpty(filter.SourceName) ? filter.SourceName : filter.FilterHeader;
                            }

                            if (string.IsNullOrEmpty(telemetry.Context.User.Id))
                            {
                                telemetry.Context.User.Id = request.UnvalidatedGetHeader(filter.UserIdHeader);
                            }

                            if (string.IsNullOrEmpty(telemetry.Context.Session.Id))
                            {
                                telemetry.Context.Session.Id = !string.IsNullOrEmpty(filter.SessionIdHeader) ?
                                    request.UnvalidatedGetHeader(filter.SessionIdHeader) :
                                    filterHeader;
                            }
                        }
                    }
                }
            }
        }
开发者ID:jawn,项目名称:ApplicationInsights-server-dotnet,代码行数:42,代码来源:WebTestTelemetryInitializer.cs


注:本文中的System.Web.HttpContext.GetRequest方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。