本文整理汇总了C#中IRequestContext.GetHeader方法的典型用法代码示例。如果您正苦于以下问题:C# IRequestContext.GetHeader方法的具体用法?C# IRequestContext.GetHeader怎么用?C# IRequestContext.GetHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRequestContext
的用法示例。
在下文中一共展示了IRequestContext.GetHeader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Analyze
/// <summary>
/// Analyze a request for potential intrusion or other problems.
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public Report Analyze(IRequestContext request)
{
var report = new Report();
string ipAddress = request.RemoteIpAddress;
string forwardedFor = request.GetHeader("X-Forwarded-For");
if(!string.IsNullOrEmpty(forwardedFor))
{
bool recognizedProxyAddress = IsRecognizedReverseProxyAddress(ipAddress);
forwardedFor = RewriteForwardedAddress(forwardedFor, ipAddress, recognizedProxyAddress);
if(!string.IsNullOrEmpty(forwardedFor) && ipAddress != forwardedFor)
{
ipAddress = forwardedFor;
report.RemoteAddressRewriteAdvised = true;
}
report.ForwardedIpAddressWasRecognizedProxy = recognizedProxyAddress;
}
report.OriginalRemoteAddress = request.RemoteIpAddress;
report.RemoteAddress = ipAddress;
return report;
}
示例2: GetAuthorization
/// <summary>
/// Gets the authorization.
/// </summary>
/// <param name="httpReq">The HTTP req.</param>
/// <returns>Dictionary{System.StringSystem.String}.</returns>
public static AuthorizationInfo GetAuthorization(IRequestContext httpReq)
{
var header = httpReq.GetHeader("Authorization");
var auth = GetAuthorization(header);
string userId;
string deviceId;
string device;
string client;
string version;
auth.TryGetValue("UserId", out userId);
auth.TryGetValue("DeviceId", out deviceId);
auth.TryGetValue("Device", out device);
auth.TryGetValue("Client", out client);
auth.TryGetValue("Version", out version);
return new AuthorizationInfo
{
Client = client,
Device = device,
DeviceId = deviceId,
UserId = userId,
Version = version
};
}
示例3: FieldsFromHeader
public static string FieldsFromHeader(IRequestContext requestContext, string fieldsHeaderName)
{
return requestContext.GetHeader(fieldsHeaderName) ?? string.Empty;
}