简体   繁体   English

是否可以在MVC控制器中附加查询字符串

[英]Is that possible to append the querystring in the controller for MVC

I'm trying to append values to the URL in the server side action. 我正在尝试在服务器端操作中将值附加到URL。 Is that possible? 那可能吗? Looks like we have to do that from the browser side when submit the request. 看起来我们在提交请求时必须从浏览器端执行此操作。 Is there an generic way to add querystring to the URL? 有没有将查询字符串添加到URL的通用方法?

Yes it is possible ... Use JavaScript to append the selected value to the domain before it submits. 是的,可以...使用JavaScript将选定的值附加到域中,然后再提交。 Change the button to have an onclick attribute as oppose to making it submit the form. 更改按钮以使其具有onclick属性,以使其提交表单。

Add this JavaScript to your head section (or wherever you want, but convention is typically the HEAD section or bottom of the body) 将此JavaScript添加到您的head部分(或您想要的任何位置,但约定通常是HEAD部分或主体底部)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM