0

I'm trying to figure out when rolling my own custom membership provider (not inheriting from the ASP.NET membership) if I need to work with the IPrincipal and IIdentity. I mean isn't that only used for non-public sites where you are working with a windows based account?

also I want to be creating my own cookie to store auth data, not the .ASPXAUTH cookie.

We are also creating our own Role Provider so we wouldn't be using the Context.User.IsInRole functionality I would assume with IIdentity.

1
  • May I ask why you want to do this? Feb 6, 2012 at 16:37

1 Answer 1

2

I mean isn't that only used for non-public sites where you are working with a windows based account?

Not at all. Those interfaces are used with the membership provider no matter what kind of authentication scheme you are using. For example the User property of HttpContext is an IPrincipal which contains an Identity property of type IIdentity. So no matter what kind of authentication you are using you should be working with those interfaces. Of course you could write your own custom implementations.

3
  • yea I just realized that...I always use HttpContext and yea I see now. Duh. We aren't using the membership provider we are rolling our own and was just making sure that our code has nothing to do related to the ASP.NET Membership provider. In other words we are rolling our own way to do stuff and our own DB tables to auth a user. We don't like how the ASP.NET Membership is providing this out of the box. Feb 6, 2012 at 16:40
  • when you say write your own custom implementations, that is kinda what we wanna do. We will grab the current user info from HttpContext. I was also looking at this blog post: bradygaster.com/custom-authentication-with-mvc-3.0 Feb 6, 2012 at 16:42
  • @CoffeeAddict I would recommend abstracting out the user and not accessing it directly from HttpContext. This will make unit testing your controllers much easier.
    – Dismissile
    Feb 6, 2012 at 17:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.