Пример #1
0
        private async Task addChannelIdentityAsync(RssFeedWriter rssFeedWriter)
        {
            await rssFeedWriter.WriteDescription(_feedChannel.FeedDescription.ApplyRle().RemoveHexadecimalSymbols());

            await rssFeedWriter.WriteCopyright(_feedChannel.FeedCopyright.ApplyRle().RemoveHexadecimalSymbols());

            await rssFeedWriter.WriteTitle(_feedChannel.FeedTitle.ApplyRle().RemoveHexadecimalSymbols());

            await rssFeedWriter.WriteLanguage(new CultureInfo(_feedChannel.CultureName));

            await rssFeedWriter.WriteRaw($"<atom:link href=\"{_httpContextInfo.GetRawUrl()}\" rel=\"self\" type=\"application/rss+xml\" />");

            await rssFeedWriter.Write(new SyndicationLink(_httpContextInfo.GetBaseUri(), relationshipType : RssElementNames.Link));
        }
Пример #2
0
        public async Task OnActionExecutionAsync(
            ActionExecutingContext context,
            ActionExecutionDelegate next)
        {
            // Do something before the action executes.
            var userAgent = context.HttpContext?.Request?.Headers["User-Agent"].ToString();
            var userIp    = context.HttpContext?.Connection?.RemoteIpAddress?.ToString();

            var userOs      = VisitorsStatisticsHelper.GetUserOsName(userAgent);
            var browserName = VisitorsStatisticsHelper.GetUserBrowserName(userAgent);
            var deviceName  = VisitorsStatisticsHelper.GetUserDeviceName(userAgent);

            //var url = Url.Action("Index", "Home", null, ViewContext.HttpContext.Request.Scheme);

            var getIp = _httpRequestInfoService.GetIP();

            var getHeaderValue = _httpRequestInfoService.GetHeaderValue("Accept-Language");

            var getUserAgent = _httpRequestInfoService.GetUserAgent();

            var absoluteContent  = _httpRequestInfoService.AbsoluteContent("~/");
            var absoluteContent2 = _httpRequestInfoService.AbsoluteContent(context.HttpContext?.Request?.Path.Value ?? "~/");

            var getBaseUrl = _httpRequestInfoService.GetBaseUrl();

            var getRawUrl = _httpRequestInfoService.GetRawUrl();

            //var getUrlTitleAsync = await _htmlHelperService.GetUrlTitleAsync(context.HttpContext?.Request?.Path.Value ?? "~/");

            var getUrlHelper = _httpRequestInfoService.GetUrlHelper().Content(context.HttpContext?.Request?.Path.Value ?? "~/");

            var viewModel = new VisitorsStatisticsViewModel()
            {
                UserAgent   = userAgent,
                UserOs      = userOs.ToString(),
                BrowserName = browserName.ToString(),
                DeviceName  = deviceName.ToString(),
                IpAddress   = userIp,
                PageViewed  = null,
                VisitDate   = DateTimeOffset.UtcNow,
            };

            await _statService.InsertAsync(viewModel);

            // next() calls the action method.
            var resultContext = await next();

            // resultContext.Result is set.
            // Do something after the action executes.
        }