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


C# UrlBuilder.ToString方法代码示例

本文整理汇总了C#中UrlBuilder.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# UrlBuilder.ToString方法的具体用法?C# UrlBuilder.ToString怎么用?C# UrlBuilder.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UrlBuilder的用法示例。


在下文中一共展示了UrlBuilder.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertUrlToExternal

        public string ConvertUrlToExternal(PageData pageData = null, PageReference p = null)
        {
            if (pageData == null && p == null)
            {
                return string.Empty;
            }
            var page = pageData ?? _repository.Get<PageData>(p);

            var pageUrlBuilder = new UrlBuilder(page.LinkURL);

            Global.UrlRewriteProvider.ConvertToExternal(pageUrlBuilder, page.PageLink, Encoding.UTF8);

            string pageURL = pageUrlBuilder.ToString();

            UriBuilder uriBuilder = new UriBuilder(SiteDefinition.Current.SiteUrl);

            uriBuilder.Path = pageURL;
            var jj = ServiceLocator.Current.GetInstance<UrlResolver>().GetUrl(p);
            if (uriBuilder.Path == "/")
                return uriBuilder.Uri.AbsoluteUri;

            string[] words = uriBuilder.Uri.AbsoluteUri.Split(new char[] {':', '/', '.'},
                        StringSplitOptions.RemoveEmptyEntries);
            bool reoccurs = words.Count(q => q == "http") > 1;

            if (reoccurs)
                return uriBuilder.Uri.LocalPath.StartsWith("/") ? uriBuilder.Uri.LocalPath.Remove(0,1) : uriBuilder.Uri.LocalPath;

            return uriBuilder.Uri.AbsoluteUri;
        }
开发者ID:EpiCenterADC,项目名称:EPICenter,代码行数:30,代码来源:PageService.cs

示例2: Serialize

        /// <summary>
        /// Serialize to XElement
        /// </summary>
        /// <returns></returns>
        public override XElement Serialize(XNamespace namespaceXForms)
        {
            var builder = new UrlBuilder(GetFormAction());
            if (this.RecipientEmailAddress != null)
            {
                builder.QueryCollection.Add("to", this.RecipientEmailAddress);
            }
            if (this.SenderEmailAddress != null)
            {
                builder.QueryCollection.Add("from", this.SenderEmailAddress);
            }
            if (this.EmailSubject != null)
            {
                builder.QueryCollection.Add("subject", this.EmailSubject);
            }

            var formElement = new XElement(namespaceXForms + "submit",
                    new XAttribute("action", builder.ToString()),
                    new XAttribute("method", string.Empty),
                    new XAttribute("name", "ctl00$FullRegion$FormControl$ctl11"));

            var formLabelElement = new XElement(namespaceXForms + "label", this.ButtonText);
            formElement.Add(formLabelElement);

            return formElement;
        }
开发者ID:alfnilsson,项目名称:EPiServerStronglyTypedXForms,代码行数:30,代码来源:SubmitButtonFormFieldModel.cs

示例3: GetExternalUrl

        /// <summary>
        /// Adds scheme and host to a relative url.
        /// </summary>
        /// <param name="input">Url</param>
        /// <returns>String</returns>
        public static string GetExternalUrl(this string input)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                return string.Empty;
            }

            var siteUri = HttpContext.Current != null
                            ? HttpContext.Current.Request.Url
                            : SiteDefinition.Current.SiteUrl;

            if (!input.StartsWith("/"))
            {
                input = "/" + input;
            }

            var urlBuilder = new UrlBuilder(input)
            {
                Scheme = siteUri.Scheme,
                Host = siteUri.Host,
                Port = siteUri.Port
            };

            return urlBuilder.ToString();
        }
开发者ID:dnasir,项目名称:EPi.Extensions,代码行数:30,代码来源:StringExtensions.cs

示例4: UrlBuilder_TestUrlShouldRemainTheSame_NoAdditionalQueryParameters

       public void UrlBuilder_TestUrlShouldRemainTheSame_NoAdditionalQueryParameters(string url, string expected)
        {
            //Arrange
            
            //Act
            var builder = new UrlBuilder(url);

            //Assert
            Assert.AreEqual(expected, builder.ToString());
        }
开发者ID:mikeedwards83,项目名称:Glass.Mapper,代码行数:10,代码来源:UrlBuilderFixture.cs

示例5: AddToQueryString_AddsCompleteString_ReturnsValueUrl

        public void AddToQueryString_AddsCompleteString_ReturnsValueUrl(string url, string expected, string query)
        {
            //Arrange
            var builder = new UrlBuilder(url);

            //Act
            builder.AddToQueryString(query);

            //Assert
            Assert.AreEqual(expected, builder.ToString());
        }
开发者ID:mikeedwards83,项目名称:Glass.Mapper,代码行数:11,代码来源:UrlBuilderFixture.cs

示例6: GetUrl

        /// <exclude />
        public static string GetUrl(IMediaFile file, bool isInternal, bool downloadableMedia)
        {
            string url = MediaUrls.BuildUrl(file, isInternal ? UrlKind.Internal : UrlKind.Public);

            if (!downloadableMedia) return url;

            var urlBuilder = new UrlBuilder(url);
            urlBuilder["download"] = "true";

            return  urlBuilder.ToString();
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:12,代码来源:MediaUrlHelper.cs

示例7: it_can_create_with_defaults

        public void it_can_create_with_defaults()
        {
            // Arrange
            var connectionString = "http://";

            // Act
            var builder = new UrlBuilder();

            // Assert
            Assert.AreEqual(null, builder.Server);
            Assert.AreEqual(null, builder.EdgeMartName);
            Assert.AreEqual(connectionString, builder.ToString());
        }
开发者ID:sprucemedia,项目名称:oinq,代码行数:13,代码来源:UrlBuilderTests.cs

示例8: it_can_create_with_a_host

        public void it_can_create_with_a_host()
        {
            // Arrange
            var connectionString = String.Format("http://{0}:{1}/remote", SERVER_NAME, DEFAULT_PORT.ToString());

            // Act
            var builder = new UrlBuilder() { Server = new ServerAddress(SERVER_NAME) };

            // Assert
            Assert.AreEqual(SERVER_NAME, builder.Server.Host);
            Assert.AreEqual(DEFAULT_PORT, builder.Server.Port);
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new UrlBuilder(connectionString).ToString());
        }
开发者ID:sprucemedia,项目名称:oinq,代码行数:14,代码来源:UrlBuilderTests.cs

示例9: it_can_create_with_a_host_and_port

        public void it_can_create_with_a_host_and_port()
        {
            // Arrange
            Int32 port = 12345;
            var connectionString = String.Format("http://{0}:{1}/remote", SERVER_NAME, port.ToString());

            // Act
            var builder = new UrlBuilder() { Server = new ServerAddress(SERVER_NAME, port) };

            // Assert
            Assert.AreEqual(SERVER_NAME, builder.Server.Host);
            Assert.AreEqual(port, builder.Server.Port);
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new UrlBuilder(connectionString).ToString());
        }
开发者ID:sprucemedia,项目名称:oinq,代码行数:15,代码来源:UrlBuilderTests.cs

示例10: it_can_create_with_a_host_and_port_and_database

        public void it_can_create_with_a_host_and_port_and_database()
        {
            // Arrange
            Int32 port = 12345;
            var connectionString = String.Format("http://{0}:{1}/remote?edgemart={2}", SERVER_NAME, port.ToString(), EDGEMART_NAME);

            // Act
            var builder = new UrlBuilder() { Server = new ServerAddress(SERVER_NAME, port), EdgeMartName = EDGEMART_NAME };

            // Assert
            Assert.AreEqual(SERVER_NAME, builder.Server.Host);
            Assert.AreEqual(port, builder.Server.Port);
            Assert.AreEqual(EDGEMART_NAME, builder.EdgeMartName);
            Assert.AreEqual(connectionString, builder.ToString());
            Assert.AreEqual(connectionString, new UrlBuilder(connectionString).ToString());
        }
开发者ID:sprucemedia,项目名称:oinq,代码行数:16,代码来源:UrlBuilderTests.cs

示例11: ExternalURLFromReference

        public static string ExternalURLFromReference(this PageReference p)
        {
            PageData page = DataFactory.Instance.Get<PageData>(p);

            UrlBuilder pageURLBuilder = new UrlBuilder(page.LinkURL);

            Global.UrlRewriteProvider.ConvertToExternal(pageURLBuilder, page.PageLink, UTF8Encoding.UTF8);

            string pageURL = pageURLBuilder.ToString();

            UriBuilder uriBuilder = new UriBuilder(EPiServer.Web.SiteDefinition.Current.SiteUrl);

            uriBuilder.Path = pageURL;

            return uriBuilder.Uri.AbsoluteUri;
        }
开发者ID:babickd,项目名称:Alloy,代码行数:16,代码来源:ExtensionMethods.cs

示例12: GetUrl

        public static string GetUrl(this VariationContent variant, ILinksRepository linksRepository, UrlResolver urlResolver)
        {
            var productLink = variant.GetParentProducts(linksRepository).FirstOrDefault();
            if (productLink == null)
            {
                return string.Empty;
            }

            var urlBuilder = new UrlBuilder(urlResolver.GetUrl(productLink));

            if (variant.Code != null)
            {
                urlBuilder.QueryCollection.Add("variationCode", variant.Code);
            }
            
            return urlBuilder.ToString();
        }
开发者ID:adrian18hd,项目名称:Quicksilver,代码行数:17,代码来源:ContentExtensions.cs

示例13: GetHtmlBodyForMail

        public string GetHtmlBodyForMail(ContentReference mailReference, NameValueCollection nameValueCollection, string language)
        {
            var urlBuilder = new UrlBuilder(_urlResolver.GetUrl(mailReference, language))
            {
                QueryCollection = nameValueCollection
            };

            var basePath = _httpContextBase.Request.Url.GetLeftPart(UriPartial.Authority);
            var relativePath = urlBuilder.ToString();
            
            if (relativePath.StartsWith(basePath))
            {
                relativePath = relativePath.Substring(basePath.Length);
            }

            return _htmlDownloader.Download(basePath, relativePath);
        }
开发者ID:adrian18hd,项目名称:Quicksilver,代码行数:17,代码来源:MailService.cs

示例14: CreateTransform

        public TransformResult CreateTransform(CreateTransformParams parameters)
        {
            UrlBuilder urlBuilder = new UrlBuilder(
                m_api.ApiUrlV.
                ResourceType("transformations").
                Add(parameters.Name).
                BuildUrl());

            urlBuilder.QueryString["transformation"] = parameters.Transform.Generate();

            using (HttpWebResponse response = m_api.Call(
                HttpMethod.POST, urlBuilder.ToString(), null, null))
            {
                TransformResult result = TransformResult.Parse(response);
                return result;
            }
        }
开发者ID:iitr-ankur,项目名称:CloudinaryMono,代码行数:17,代码来源:Cloudinary.cs

示例15: GenerateUrl

 public static string GenerateUrl(string controller, string action, 
     object[] parameters, List<KeyValuePair<string, string>> urlParam)
 {
     string appPath = HttpContextHandler.Instance.ApplicationPath.ToLower();
     var url = new StringBuilder();
     url.Append(appPath);
     if (!string.IsNullOrEmpty(appPath) && !appPath.EndsWith("/"))
     {
         url.Append("/");
     }
     url.Append(controller.ToLower()).Append("/");
     if (!string.IsNullOrEmpty(action))
     {
         url.Append(action.ToLower()).Append("/");
     }
     if (parameters != null)
     {
         foreach (var o in parameters)
         {
             if (o != null)
             {
                 AppendParameter(url, o);
             }
         }
     }
     url.Length--;
     if (WebSettings.MvcPostfix != "")
     {
         url.Append(WebSettings.MvcPostfix);
     }
     var s =  url.ToString();
     if(urlParam != null)
     {
         var ub = new UrlBuilder(s, Encoding.UTF8);
         foreach (var kv in urlParam)
         {
             ub.Add(kv.Key, kv.Value);
         }
         return ub.ToString();
     }
     return s;
 }
开发者ID:991899783,项目名称:DbEntry,代码行数:42,代码来源:UrlToInfo.cs


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