Nie*_*ein 84 javascript c# jquery url.action
我想将变量itemId和entityModel发送到ActionResult CreateNote:
public ActionResult CreateNote(
[ModelBinder(typeof(Models.JsonModelBinder))]
NoteModel Model, string cmd, long? itemId, string modelEntity)
Run Code Online (Sandbox Code Playgroud)
用这个javascript:
Model.meta.PostAction = Url.Action("CreateNote", new { cmd = "Save", itemId = itemId, modelEntity = modelEntity});
Run Code Online (Sandbox Code Playgroud)
但是,发送的网址是
localhost:1304/Administration/blue/en-gb/Entity/CreateNote?modelEntity=Phrase&itemId=44
Run Code Online (Sandbox Code Playgroud)
我想发送
localhost:1304/Administration/blue/en-gb/Entity/CreateNote?modelEntity=Phrase&itemId=44
Run Code Online (Sandbox Code Playgroud)
如何防止Url.Action将&发送到我要发送的第二个变量的前面?
K. *_*Bob 120
昨天我没有注意到你曾经&
认为SO编辑改变了这一点.尝试包装你Url.Action()
的a @Html.Raw()
以防止&的编码.
或者只Url.Action()
选择控制器/动作位并将两个参数作为后置数据传递而不是直接传递给url,jQuery应该以这种方式为你排序.
Kei*_*ith 13
我认为你的问题在于Model.meta.PostAction
- 是属性string
吗?
如果是这样,那么我的猜测就是你将它添加到页面中:
@Model.meta.PostAction
<%:Model.meta.PostAction%>
两者都会自动为您编码该字符串.
要修复它,要么使用@Html.Raw()
/ <%=
(两者都不编码),要么使PostAction
属性IHtmlString
知道它已被编码:
string actionUrl = Url.Action("CreateNote", new { cmd = "Save", itemId = itemId, modelEntity = modelEntity});
Model.meta.PostAction = new HtmlString(actionUrl);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
31095 次 |
最近记录: |