Umbraco - 如何插入其中有空格的字段?

Umbraco - how to insert a field that has spaces in it?

我有 umbraco v7.2.8

我有一些这样的模板代码

<input type="hidden" name="search" value=@Request.QueryString["search"]>

这很适合将搜索字符串的查询字符串值放入隐藏字段,因此当我单击周围表单上的提交时,它会重新查询。

但是,当搜索字符串中有空格时,Umbraco 会自行变聪明,将 "red tree" 更改为 "red" tree=""

这令人沮丧,并且似乎也发生在字段中 - 这一定是一个很常见的问题。我可以对其进行 URLEncode,但是当我单击提交按钮时,它会再次进行编码,这显然是不可取的,所以我基本上希望发生以下情况

QueryString?Search=red+tree

模板:<input type="hidden" name="search" value=@Request.QueryString["search"]>

变成:<input type="hidden" name="search" value="red tree"> 不:<input type="hidden" name="search" value="red" tree="">

注意 <input type="hidden" name="search" value=@HttpUtility.UrlEncode(Request.QueryString["search"])> 给出 <input type="hidden" name="search" value="red+tree"> 这又不是我需要的

这不是 Umbraco,这是因为您没有将您的值用引号引起来。如果您将代码修改为:

<input type="hidden" name="search" value="@Request.QueryString["search"]">

它应该如您所愿地工作。