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


C# IRequestContext.GetHeader方法代码示例

本文整理汇总了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;
        }
开发者ID:RetroRabbit,项目名称:Mike,代码行数:29,代码来源:MikeIds.cs

示例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
            };
        }
开发者ID:Kampari,项目名称:MediaBrowser,代码行数:32,代码来源:AuthorizationRequestFilterAttribute.cs

示例3: FieldsFromHeader

 public static string FieldsFromHeader(IRequestContext requestContext, string fieldsHeaderName)
 {
     return requestContext.GetHeader(fieldsHeaderName) ?? string.Empty;
 }
开发者ID:AnthonyCarl,项目名称:ServiceStack.PartialResponse,代码行数:4,代码来源:FieldsRetriever.cs


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