我如何在ServiceStack中使用asp.net 成员资格?(ServiceStack.OrmLite、ServiceStack.Host.AspNet 等)
2 回答
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.
如果您想使用成员资格,并且想将 ORM lite 与成员资格框架一起使用(尽管您仍然可以使用 SqlMembershipProvider),您可以像这样创建一个自定义提供程序类:
public class ServiceStackMembershipProvider : MembershipProvider
{
}
并使用 ORM 组件实现所有方法(或至少是您需要的方法)。