websitepanel/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Extensions/UriExtensions.cs
2014-12-03 11:43:26 +03:00

25 lines
No EOL
890 B
C#

using System;
using System.Web;
namespace WebsitePanel.WebDavPortal.Extensions
{
public static class UriExtensions
{
/// <summary>
/// Adds the specified parameter to the Query String.
/// </summary>
/// <param name="url"></param>
/// <param name="paramName">Name of the parameter to add.</param>
/// <param name="paramValue">Value for the parameter to add.</param>
/// <returns>Url with added parameter.</returns>
public static Uri AddParameter(this Uri url, string paramName, string paramValue)
{
var uriBuilder = new UriBuilder(url);
var query = HttpUtility.ParseQueryString(uriBuilder.Query);
query[paramName] = paramValue;
uriBuilder.Query = query.ToString();
return new Uri(uriBuilder.ToString());
}
}
}