public string CompositeUrlBuilder() { HttpContext context = System.Web.HttpContext.Current; UrlBuilder urlBuilder = new UrlBuilder(context.Request.RawUrl); urlBuilder.ServerUrl = new UrlBuilder(context.Request.Url.ToString()).ServerUrl; return urlBuilder.ToString(); }
/// <summary> /// Redirect to page with query string parameter returnUrl /// </summary> /// <param name="pageId"></param> /// <param name="returnUrl"></param> public static bool Redirect(Guid pageId, string returnUrl) { string pageUrl; PageStructureInfo.TryGetPageUrl(pageId, out pageUrl); if (!string.IsNullOrEmpty(pageUrl)) { if (!string.IsNullOrEmpty(returnUrl)) { var urlBuilder = new UrlBuilder(pageUrl); var queryParameters = new NameValueCollection(); queryParameters.Add("returnUrl", returnUrl); urlBuilder.AddQueryParameters(queryParameters); pageUrl = urlBuilder.ToString(); } HttpContext.Current.Response.Redirect(pageUrl, false); return true; } return false; }
internal static PageUrl ParsePublicUrl(UrlBuilder urlBuilder, out NameValueCollection notUsedQueryParameters) { UrlKind urlKind; PageUrlData pageUrlData = PageUrls.ParseUrl(urlBuilder.ToString(), out urlKind); if (pageUrlData == null || urlKind != UrlKind.Public) { notUsedQueryParameters = null; return null; } notUsedQueryParameters = pageUrlData.QueryParameters; return new PageUrl(pageUrlData.PublicationScope, pageUrlData.LocalizationScope, pageUrlData.PageId, PageUrlType.Public); }
/// <exclude /> public string GetResizedImageUrl(string storeId, Guid mediaId, ResizingOptions resizingOptions) { IMediaFile file = GetFileById(storeId, mediaId); if (file == null) { return null; } string pathToFile = UrlUtils.Combine(file.FolderPath, file.FileName); pathToFile = RemoveForbiddenCharactersAndNormalize(pathToFile); // IIS6 doesn't have wildcard mapping by default, so removing image extension if running in "classic" app pool if (!HttpRuntime.UsingIntegratedPipeline) { int dotOffset = pathToFile.IndexOf(".", StringComparison.Ordinal); if (dotOffset >= 0) { pathToFile = pathToFile.Substring(0, dotOffset); } } string mediaStore = string.Empty; if (!storeId.Equals(DefaultMediaStore, StringComparison.InvariantCultureIgnoreCase)) { mediaStore = storeId + "/"; } var url = new UrlBuilder(UrlUtils.PublicRootPath + "/media/" + mediaStore + /* UrlUtils.CompressGuid(*/ mediaId /*)*/) { PathInfo = file.LastWriteTime != null ? "/" + GetDateTimeHash(file.LastWriteTime.Value.ToUniversalTime()) : string.Empty }; if (pathToFile.Length > 0) { url.PathInfo += pathToFile; } if (resizingOptions != null && !resizingOptions.IsEmpty) { return url + "?" + resizingOptions; } return url.ToString(); }