如何通过在ASP.NET MVC改变阻止访问URL到控制器? [英] How to block access to controller via changing Url in ASP.NET MVC?
问题描述
我想成功的消息访问页面只有当用户点击按钮...
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屋!