简体   繁体   English

授权MVC3 ASP.NET

[英]Authorization MVC3 ASP.NET

this is what I'm doing: 1: Custom Authorization which loads Home/NoAccess 2: the NoAccess method will redirect to the page the user came from. 这就是我正在做的事情:1:加载Home / NoAccess的自定义授权2:NoAccess方法将重定向到用户来自的页面。

What I want added to this, is that when the user goes through the NoAccess controller something is placed in the viewbag or we. 我要补充的是,当用户通过NoAccess控制器时,某些东西会放在视图包或我们中。 that I can use to show a small messagebox saying something like "You've got no access". 我可以使用它来显示一个小消息框,显示诸如“您无权访问”之类的信息。

The problem I am having is that when I put something in my ViewBag it doesn't reach the View. 我遇到的问题是,当我在ViewBag中放入某些东西时,它无法到达View。 Is there an easy way to redirect the user to his previous page when he doesn't pass authorization and show a alert popup? 当用户未通过授权并显示警告弹出窗口时,是否有一种简单的方法可以将用户重定向到其上一页?

The ViewBag contents is lost in the redirect. ViewBag内容在重定向中丢失。

Use TempData instead. 请改用TempData The contents are stored until it's read. 内容一直存储到读取为止。

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

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