Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use ASP.NET Membership in ServiceStack

how can i use asp.net membership in ServiceStack ? (ServiceStack.OrmLite , ServiceStack.Host.AspNet , etc )

like image 810
mehrdad Avatar asked Jan 03 '12 11:01

mehrdad


2 Answers

You can host ServiceStack on a custom path, i.e. at /api which lets you run ASP.NET web forms and ServiceStack side-by-side and then use the normal ASP.NET membership provider in ASP.NET.

You can then share UserSessions with ServiceStack using its Session Provider, here's an example on how to instantiate a Session with MVC - you can use this same class with ASP.NET.

The alternative is to forgo the ASP.NET membership provider and just stick to the built-in authentication in ServiceStack. It includes support for Credentials (i.e. user/pass - what you want) but also Twitter / Facebook / BasicAuth + your own. With In-Memory, OrmLite and Redis backends.

Here's an example website of using all authentication options in the same ServiceStack app with an OrmLite backend.

like image 85
mythz Avatar answered Oct 13 '22 05:10

mythz


If you want to use membership, and want to use the ORM lite with the membership framework (although you could still use the SqlMembershipProvider), you can create a custom provider class like so:

public class ServiceStackMembershipProvider : MembershipProvider
{

}

And implement all the methods (or at least the methods you need) using the ORM components.

like image 20
Brian Mains Avatar answered Oct 13 '22 05:10

Brian Mains