如何使用[授权]和[FacebookAuthorize]在MVC3 Web应用程序使用混合会员 [英] How to use [Authorize] and [FacebookAuthorize] in mvc3 web app using mixed membership

查看:140
本文介绍了如何使用[授权]和[FacebookAuthorize]在MVC3 Web应用程序使用混合会员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用我们的第一个网站,这将使用户或者使用我们的标准.NET成员提供或使用Facebook C#SDK的Facebook的选择(真棒SDK的方式!)。

We are using our first website that will give the users the choice of either using our standard .net membership provider or facebook using the facebook c# sdk (awesome sdk by the way!).

我们已经处理了大部分,但需要限制访问基于被记录或没有用户的特定区域。在用纯水达网络成员过去我们使用的方法中的[授权]属性,但是如果用户在用Facebook那么这是假的记录

We have handled most of it but need to restrict access to certain areas based on the user being logged in or not. In the past with pure .net membership we used the [Authorize] attribute on the method, however if the user is logged in using facebook then this is false.

我知道我可以尝试推出自己的dataannotation扩展。或者,我可以尝试手动一方或另一方。我知道这里也是FacebookAuthorization注释。我想最好要使用这些批注(如,如果用户没有登录都将进入同一个登录页面)。

I know I can try to roll our own dataannotation extension. Or I could just manually try one or the other. I know there is also the FacebookAuthorization annotation. I would ideally like to use these annotations (as both would go to the same login page if the user is not logged in).

有没有人有使用混合会员使用一些dataannotation一个网站的一个很好的例子?或dataannotation扩展?

Does anyone have a good example of a site using mixed membership using some dataannotation? Or a dataannotation extension?

在此先感谢

推荐答案

召唤完成Facebook的流量的OAuth标准FomsAuthentication.SetAuthCookie方法。然后授权属性应该正常工作。

Call the standard FomsAuthentication.SetAuthCookie method upon completing the Facebook OAuth flow. The Authorize attribute should then work properly.

这篇关于如何使用[授权]和[FacebookAuthorize]在MVC3 Web应用程序使用混合会员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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