如何将值添加到查询字符串?Querystring - 在c#中为查询字符串添加值
我试图做到这一点:
String currurl = HttpContext.Current.Request.RawUrl;
var querystring = HttpContext.Current.Request.QueryString.ToString();
var PrintURL = currurl + (String.IsNullOrEmpty(querystring)) ?
HttpContext.Current.Request.QueryString.Add("print", "y") : string.Empty;
但我不断收到此错误:
Cannot implicitly convert type 'string' to 'bool'
所有我想要做的就是当前的URL,并添加普林= Y?使用到的查询字符串
正确,但你需要解释为什么。 – SLaks 2011-02-24 18:28:28
@Donut是不是HttpContext.Current.Request.QueryString只读? – Magnus 2011-02-24 18:33:20
@Donut:如前所述,这将失败,因为Request.QueryString.Add()不返回任何东西(void)。 – Nimrod 2011-02-24 18:44:22