/// <summary> /// Initializes a new instance of the <see cref="UriParts"/> class with the provided URI. /// </summary> /// <param name="uriString">The URI string.</param> public UriParts(string uriString) { _rawString = uriString; UriScheme uriScheme = new UriScheme(_rawString); _scheme = uriScheme.SchemeType; _uriWithoutScheme = _rawString.Replace(uriScheme.Prefix, string.Empty); }
/// <summary> /// Initializes a new instance of the <see cref="UriParts"/> class with the Current.Request.RawUrl. /// </summary> public UriParts() { _rawString = HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.RawUrl.TrimEnd('/'); UriScheme uriScheme = new UriScheme(_rawString); _scheme = uriScheme.SchemeType; _uriWithoutScheme = _rawString.Replace(uriScheme.Prefix, string.Empty); }
/// <summary> /// Creates a link to a mirror site at the same relative path as the current URL of this site. /// </summary> /// <param name="htmlHelper">This HTML helper.</param> /// <param name="linkText">The link text.</param> /// <param name="domain">The domain of the mirror site.</param> /// <param name="scheme">The scheme of the URL to build.</param> /// <returns>A <see cref="MvcHtmlString"/>.</returns> public static MvcHtmlString MirrorSiteLink(this HtmlHelper htmlHelper, string linkText, string domain, UriScheme scheme) { string url = scheme.Prefix + domain + "/" + UriParts.Current.UriPath.TrimStart('/'); if (UriParts.Current.Parameters != null && UriParts.Current.Parameters.Count > 0) url += "?" + UriParts.Current.QueryPart; return MvcHtmlString.Create(String.Format(HtmlStrings.LINK, url, HtmlStrings.LINK_TARGET_BLANK, linkText)); }