首页 > 解决方案 > razor 下拉列表中的 UrlDecode 未解码字符串

问题描述

UrlDecode 不解码剃刀下拉列表中的字符串。这是我尝试过的:

我试过使用 WebUtility.UrlDecode 和 HttpUtility.UrlDecode

@Html.DropDownListFor(m => m.questions, new SelectList(Model.questions, 
"id", WebUtility.UrlDecode("Answer")), null, new { @class = "data"})

下拉列表中的字符串,例如“My%20House”未解码为“My House”

标签: c#razor

解决方案


你可以使用类似的东西:

@Html.Raw(YourValue)

或者

@Html.Raw(HttpUtility.HtmlDecode(YourValue));


推荐阅读