什么是网络表单的" UrlAuthorizationModule.CheckUrlAccessForPrincipal"相当于MVC? [英] What is Webform's "UrlAuthorizationModule.CheckUrlAccessForPrincipal" equivalent for MVC?

查看:374
本文介绍了什么是网络表单的" UrlAuthorizationModule.CheckUrlAccessForPrincipal"相当于MVC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为我写为我公司定制的SSO解决方案有一个问题。为了mkae简单,我做了拦截所有请求,以检查用户身份验证状态的自定义身份验证的HttpModule。如果未通过身份验证,用户会被重定向到我的定制SSO登录页面。

I got a problem as i am writing a custom SSO solution for my company. To mkae it simple, i've made a custom authentication httpmodule that intercepts all requests so as to check user authentication state. If not authenticated, user is redirected to my custom sso login page.

问题是,当用户没有通过验证,我想检查他是否能访问请求的网页/资源......随着Web表单,没问题,我在web.config中添加授权块,我用 UrlAuthorizationModule.CheckUrlAccessForPrincipal 有匿名用户。一切工作正常...

The thing is, when user is not authenticated, i'd like to check if he can access the requested page/resource... With Webforms, no problem, i add an authorization block in web.config, and i use UrlAuthorizationModule.CheckUrlAccessForPrincipal with an anonymous user. Everything works fine...

但是,当我申请我的模块的 MVC(3)的网站,这不工作了(原因很明显,就像访问从型动物的网址相同的控制器和/或采取行动的可能性当使用路由,因为授权是通过控制器属性进行)。

But when i apply my module to an MVC (3) web site, this does not work anymore (for obvious reasons, like the possibility to access the same controller and/or action from differents urls when using routing, and because authorizations are made through controller attributes).

我怎样才能做到这一点?我一直在寻找长一整天,也没有找到任何东西:/

How can I achieve this ?? I've been searching all day long, didn't find anything about that :/

推荐答案

我有同样的问题。

看到这里的解决方案:<一href=\"http://stackoverflow.com/questions/19038186/mvc-equivalent-of-webforms-urlauthorizationmodule-checkurlaccessforprincipal/19038664?noredirect=1#19038664\">MVC UrlAuthorizationModule.CheckUrlAccessForPrincipal&QUOT; Web表单&QUOT相当于

I had the same problem.
See solution here: MVC equivalent of Webforms "UrlAuthorizationModule.CheckUrlAccessForPrincipal"

您必须读取来自其它控制器的信息。这个
  可以通过实例化其背景和描述符来完成,然后
  实例化AuthorizationContext该控制器和读
  过滤器的信息。

You would have to read the information from the other controller. This can be done by instantiating its context and the Descriptor, then instantiating the AuthorizationContext for that controller and read the filter info.

这篇关于什么是网络表单的&QUOT; UrlAuthorizationModule.CheckUrlAccessForPrincipal&QUOT;相当于MVC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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