ParseUrl-URL尾部添加/斜杠,CombineUrl - 拼接组合2个URL部分
ParseUrl-URL尾部添加/斜杠,CombineUrl - 拼接组合2个URL部分
C# Code:
/// <summary>
/// URL尾部添加/斜杠,
/// </summary>
/// <param name="baseUrl"></param>
/// <returns></returns>
public static string ParseUrl(string baseUrl)
{
if (!String.IsNullOrEmpty(baseUrl))
{
if (baseUrl.Substring(baseUrl.Length - 1, 1) != "/") baseUrl = baseUrl + "/";
}
return baseUrl;
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
/// URL尾部添加/斜杠,
/// </summary>
/// <param name="baseUrl"></param>
/// <returns></returns>
public static string ParseUrl(string baseUrl)
{
if (!String.IsNullOrEmpty(baseUrl))
{
if (baseUrl.Substring(baseUrl.Length - 1, 1) != "/") baseUrl = baseUrl + "/";
}
return baseUrl;
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
C# Code:
/// <summary>
/// 拼接组合2个URL段
/// </summary>
/// <param name="baseUrl"></param>
/// <param name="url2"></param>
/// <returns></returns>
public static string CombineUrl(string baseUrl, string url2)
{
//防止拼接位置出现2个//
if (baseUrl.Substring(baseUrl.Length - 1, 1) != "/") baseUrl = baseUrl + "/";
if (url2.Substring(0, 1) == "/") url2 = url2.Substring(1, url2.Length - 1);
return baseUrl + url2;
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
/// <summary>
/// 拼接组合2个URL段
/// </summary>
/// <param name="baseUrl"></param>
/// <param name="url2"></param>
/// <returns></returns>
public static string CombineUrl(string baseUrl, string url2)
{
//防止拼接位置出现2个//
if (baseUrl.Substring(baseUrl.Length - 1, 1) != "/") baseUrl = baseUrl + "/";
if (url2.Substring(0, 1) == "/") url2 = url2.Substring(1, url2.Length - 1);
return baseUrl + url2;
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网