Url.Action提出的&放大器;放大器;在我的网址,我怎么能解决这个问题? [英] Url.Action puts an & in my url, how can I solve this?
问题描述
我要变量的itemId和entityModel发送到的ActionResult CreateNote:
公众的ActionResult CreateNote(
[ ModelBinder的(typeof运算(Models.JsonModelBinder))]
NoteModel型号,串CMD,长时间?的itemId,串modelEntity)
通过这个JavaScript:
Model.meta.PostAction = Url.Action(CreateNote,新{ CMD =保存,的itemId =的itemId,modelEntity = modelEntity});
不过,URL为send为
本地主机:1304 /行政/蓝/ EN-GB /实体/ CreateNote modelEntity =短语和放大器;放大器;的itemId = 44
$ p? $ p>
我要发
本地主机:1304 /行政/蓝/ ?EN-GB /实体/ CreateNote modelEntity =短语和放大器;的itemId = 44
如何阻止URL。行动把&放大器;在我想要发送的第二个变量的面前?
解决方案我昨天没注意到你有
&放大器;放大器;
我认为这是对SO编辑已经改变了这一切。试试你的包裹Url.Action()
在@ Html.Raw()
来防止和放大器;.的编码
或仅
Url.Action()
控制器/动作位,并通过这两个参数后的数据,而不是直接的URL,jQuery的应该理清和放大器;给你的那种方式。I want to send the variables itemId and entityModel to the ActionResult CreateNote:
public ActionResult CreateNote( [ModelBinder(typeof(Models.JsonModelBinder))] NoteModel Model, string cmd, long? itemId, string modelEntity)
with this javascript:
Model.meta.PostAction = Url.Action("CreateNote", new { cmd = "Save", itemId = itemId, modelEntity = modelEntity});
However, the url being send is
localhost:1304/Administration/blue/en-gb/Entity/CreateNote?modelEntity=Phrase&itemId=44
I want to send
localhost:1304/Administration/blue/en-gb/Entity/CreateNote?modelEntity=Phrase&itemId=44
How can I prevent Url.Action to put the & in front of the second variable that I want to send?
解决方案I didn't notice yesterday that you had
&
I thought that was the SO editor had changed that. Try wrapping yourUrl.Action()
in a@Html.Raw()
to prevent the Encode of &.Or alternatively only
Url.Action()
the controller/action bit and pass the two parameters as post data rather than directly on the url, jQuery should sort out the &'s for you that way.这篇关于Url.Action提出的&放大器;放大器;在我的网址,我怎么能解决这个问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!