Use ASP.NET Membership in ServiceStack

2019-03-30 02:41发布

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

2条回答
叛逆
2楼-- · 2019-03-30 03:32

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.

查看更多
女痞
3楼-- · 2019-03-30 03:36

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.

查看更多
登录 后发表回答