1 Star 0 Fork 662

CyrusZhou/OpenAuth.Core

forked from 李玉宝/OpenAuth.Core
暂停
 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
UriUtil.cs 1.79 KB
一键复制 编辑 原始数据 按行查看 历史
李玉宝 提交于 2021-10-04 01:05 . 优化注释
// ***********************************************************************
// Assembly : Infrastructure
// Author : yubaolee
// Created : 06-21-2016
//
// Last Modified By : yubaolee
// Last Modified On : 06-22-2016
// Contact :
// File: UriUtil.cs
// ***********************************************************************
using System;
using System.Collections.Specialized;
using System.Web;
namespace Infrastructure.Utilities
{
/// <summary>
/// URl帮助类
/// </summary>
public class UriUtil
{
/// <summary>
/// 在URL后面追加参数
/// </summary>
/// <param name="url"></param>
/// <param name="key"></param>
/// <param name="value"></param>
/// <returns></returns>
public static string GetAppendedQueryString(string url, string key, string value)
{
if (url.Contains("?"))
{
url = string.Format("{0}&{1}={2}", url, key, value);
}
else
{
url = string.Format("{0}?{1}={2}", url, key, value);
}
return url;
}
public static string RemoveParameter(string url, string key)
{
url = url.ToLower();
key = key.ToLower();
if (!url.Contains(key + "=")) return url;
Uri uri = new Uri(url);
NameValueCollection collection = HttpUtility.ParseQueryString(uri.Query);
if (collection.Count == 0) return url;
var val = collection[key];
string fragmentToRemove = string.Format("{0}={1}",key , val);
String result = url.ToLower().Replace("&" + fragmentToRemove, string.Empty).Replace("?" + fragmentToRemove, string.Empty);
return result;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C#
1
https://gitee.com/CyrusZHou/OpenAuth.Core.git
[email protected]:CyrusZHou/OpenAuth.Core.git
CyrusZHou
OpenAuth.Core
OpenAuth.Core
master

搜索帮助