隐藏MVC应用程序中地址栏中的参数 [英] Hiding parameters in address bar in a MVC application

查看:219
本文介绍了隐藏MVC应用程序中地址栏中的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过超链接在控制器动作方法中传递一些参数。

我需要隐藏地址栏中的参数并仅显示Action方法名称。

例如http:// localhost / Controller / MethodName



谁能告诉我这是怎么实现的?



我尝试过:



我使用查询字符串来传递数据,但必须避免这种情况。我试图将数据分配给隐藏变量并传递模型。即便如此,数据也会出现在地址栏中。

解决方案

如果您执行POST而不是GET,则只能隐藏参数。要做到这一点,您的超链接将需要执行javascript,将表单提交到您的操作而不是正常的超链接。



你不应该花时间去做的事情。 ASP.NET论坛 [ ^ ]

I am passing some parameters in a controller action method through a Hyperlink.
I need to hide the parameters in the address bar and show only the Action method name.
For e.g. http://localhost/Controller/MethodName

Can anyone tell me how this can be achieved?

What I have tried:

I have used query string to pass the data, but that has to be avoided. I tried to assign the data to a hidden variable and pass the model. Even then the data is coming in the address bar.

解决方案

You can only hide the parameters if you do a POST rather than a GET. To do this your hyperlink will need to execute javascript that submits a form to your action rather than being a normal hyperlink.

Things you shouldn't spend time doing | The ASP.NET Forums[^]


这篇关于隐藏MVC应用程序中地址栏中的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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