本文整理汇总了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;
}
}
}
示例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;
}
}
}
}
}
}