如何通过在ASP.NET MVC改变阻止访问URL到控制器? [英] How to block access to controller via changing Url in ASP.NET MVC?

查看:96
本文介绍了如何通过在ASP.NET MVC改变阻止访问URL到控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想成功的消息访问页面只​​有当用户点击按钮...

I want to access page with Success message only, when user clicks to button...

通过更改URL,如 ... /成功我希望我的网站重定向用户previous页。

By changing url, such as .../Success I want my site redirect user to previous page.

我如何通过ASP.NET做到这一点MVC 3?

How can I do this via ASP.NET MVC 3?

推荐答案

这样做的一个快速的方法是设置包含在其中重定向操作的随机数的会话,还通过随机数作为参数传递给其他行动。

A quick way of doing that is to set a session containing a random number in the action which is redirecting, also pass the random number as a parameter to the other action.

里面的其他行动(重定向一个),用行动中的参数比较会话的价值。如果值相等,用户​​由pressing按钮到达那里,否则,用户通过更改URL到达那里。
希望它帮助。

Inside the other action(redirected one), compare the value of the session with the parameter of the action. If values are equal, the user is getting there by pressing button, otherwise, the user gets there by changing the URL. Hope it helps.

这篇关于如何通过在ASP.NET MVC改变阻止访问URL到控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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