Use ASP.NET Membership in ServiceStack

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 05:37:05

问题


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


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/8711436/use-asp-net-membership-in-servicestack

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