为url.action发布操作? [英] post action for url.action?

查看:61
本文介绍了为url.action发布操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的Controller类中的一行代码:

Here is a line of code in my Controller class:

return JavaScript(String.Format("window.top.location.href='{0}';", Url.Action("MyAction", "MyController")))

是否可以使用MyActionverb=post版本?

推荐答案

您不能通过简单地导航到其他URL来使用POST. (这是您通过更改location.href所要做的.)

You can't use POST by simply navigating to a different URL. (Which is what you'd do by changing location.href.)

仅在提交某些数据时使用POST才有意义.从您的代码尚不清楚实际将要发布哪些数据.

Using POST only makes sense when submitting some data. It's not clear from your code what data would actually be POSTed.

如果您真的想通过javascript启动POST,请尝试使用它提交表单.

If you really want to initiate a POST via javascript try using it to submit a form.

这篇关于为url.action发布操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆