How to use [Authorize] and [FacebookAuthorize] in mvc3 web app using mixed membership

牧云@^-^@ 提交于 2019-12-23 04:33:21

问题


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!).

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.

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).

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

Thanks in advance


回答1:


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




回答2:


We have used a global filter attribute. We've created that one our self. If somebody has a better idea, I'm open for suggestions!



来源:https://stackoverflow.com/questions/7139792/how-to-use-authorize-and-facebookauthorize-in-mvc3-web-app-using-mixed-membe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!