替换查询字符串中的项目 [英] Replace item in querystring
本文介绍了替换查询字符串中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个URL,它也可能包含查询字符串部分,查询字符串可能为空或包含多个项目.
I have a URL that also might have a query string part, the query string might be empty or have multiple items.
我想替换查询字符串中的一项,或者如果项不存在则添加它.
I want to replace one of the items in the query string or add it if the item doesn't already exists.
我有一个带有完整URL的URI对象.
I have an URI object with the complete URL.
我的第一个想法是使用正则表达式和一些字符串魔术,应该这样做.
My first idea was to use regex and some string magic, that should do it.
但是似乎有些不稳定,也许框架中有一些查询字符串生成器类?
But it seems a bit shaky, perhaps the framework has some query string builder class?
推荐答案
也许您可以使用System.UriBuilder
类.它具有Query
属性.
Maybe you could use the System.UriBuilder
class. It has a Query
property.
这篇关于替换查询字符串中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文