我想将 Mvc UrlHelper 与 JQuery 模板结合使用。
示例模板...
...
{{each Items}}
<div>
<%= Url.Action("Action", "Controller", new { Id = "${$value.Id}" })%>
</div>
{{/each}}
...
Url 帮助器 Action 方法对我作为 Id 参数传入的模板占位符进行编码。这呈现为..
...
<div>
/web/controller/%24%7B%24value.Id%7D/action
</div>
<div>
/web/controller/%24%7B%24value.Id%7D/action
</div>
...
我真的可以用一种方法来阻止 Action 方法对 Id 参数值进行编码,但我想它只是在做它的工作!