public IActionResult RenderOpenSearch() { return(new OpenSearchResult { ShortName = "My Site's Name", Description = "My Site's Contents Search", SearchForm = _httpRequestInfoService.GetBaseUrl(), FavIconUrl = $"{_httpRequestInfoService.GetBaseUrl()}/favicon.ico", SearchUrlTemplate = Url.Action( nameof(PublicSearch), typeof(OpenSearchController).ControllerName(), new { term = "searchTerms" }, HttpContext.Request.Scheme) }); }
/// <summary> /// Parses an HTML content and tries to convert its relative URLs to absolute urls based on the siteBaseUrl. /// </summary> public string FixRelativeUrls(string html, string imageNotFoundPath) { var siteBaseUrl = _httpRequestInfoService.GetBaseUrl(); if (string.IsNullOrWhiteSpace(siteBaseUrl)) { throw new InvalidOperationException("`siteBaseUrl` is null."); } return(FixRelativeUrls(html, imageNotFoundPath, siteBaseUrl)); }
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. }
/// <summary> /// Parses an HTML content and tries to convert its relative URLs to absolute urls based on the siteBaseUrl. /// </summary> public string FixRelativeUrls(string html, string imageNotFoundPath) { return(FixRelativeUrls(html, imageNotFoundPath, _httpRequestInfoService.GetBaseUrl())); }