Web Application Design with ServiceStack

After getting advice on using ServiceStack for my asp.net MVC website ( Maintaining State on the ASP.NET MVC Website ), I started implementing it in my project, but some things are still unclear to me.

I currently have two projects: one is an asp.net MVC project, and the other is a BL project (a class library that contains all the business logic). All controllers in the MVC project call class / function calls in the BL project.
While the mvc project is loading the BL DLL, but in the future, as the site grows, the BL project will run on separate machines.

I would like to use ServiceStack for session management / caching and authentication (which they both usually depended on each other).

My questions are:
1) Can I use only these two functions without the functionality of a message-based web service? ServiceStack needs to be initialized, and it gives me an error during initialization twice (in both projects).
2) Is it possible to split the implementation of ServiceStack between two projects? I would like to support the authentication process in the BL project using ServiceStack authentication providers, but to handle all user interfaces / cookies (or using ServiceStack) in the mvc project myself.
3) I would like to use ServiceStack caching in the BL project, but I assume that I still need to support session cookies to get the session ID. What is the right way to do this? Are there any built-in helper functions for this purpose?

Thanks in advance!

+5
source share
2 answers

1) Is it possible to use only these two functions without the functionality of a message-based web service? ServiceStack needs to be initialized, and it gives me an error during initialization twice (in both projects).

ServiceStack.Mvc NuGet, ServiceStackController, MVC-, ServiceStack. - , , , ICacheClient.

, WebSphere ServiceStack, AppHost - . ServiceStack ASP.NET IHttpHandler, Web.config, , , ServiceStack, , - :

var cache = AppHost.Resolve<ICacheClient>(); //Get ICacheClient for SS IOC

2) ServiceStack ?

AppHost, - ( ), AppHost , , - .

ServiceStack , AppHostBase, :

public class AppHost : AppHostBase 
{
   public AppHost() : base("My Service", 
     typeof(AServiceInDll1).Assembly, typeof(AServiceInDll2).Assembly/*, etc.*/){}
}

2) . BL ServiceStack, / cookie ( ServiceStack) mvc.

ServiceStack.UseCases CustomAuthenticationMvc MVC, ServiceStack.

3) ServiceStack BL, , . ? - ?

ServiceStack, #, .. - ICacheClient .

base.SessionAs<T> ServiceStack.Mvc ServiceStackController . , IHttpRequest.SaveSession(). ASP.NET( ASP.NET HttpContext singleton, ), cookie ServiceStack ss-id/ss-pid, () , .

, - ASP.NET System.Web, , , -.

, ServiceStack.

ASP.NET- ServiceStack ASP.NET MVC

, , ServiceStack ASP.NET MVC, ServiceStack .

ServiceStack IHttpRequest IHttpResponse ( HTTP/Controller):

var ssHttpRequest = System.Web.HttpContext.Current.Request.ToRequest();
var ssHttpResponse = System.Web.HttpContext.Current.Response.ToResponse(); 

, ( IHttpRequest, IHttpResponse):

var ssRequestContext = System.Web.HttpContext.Current.ToRequestContext();
+5

, . ...

- ? ServiceStack ,

, 2 ServiceStack (, 2 -) ( - BL-). , . BL- ServiceStack, ( AppHost.Configure) , -, BL.

ServiceStack ?

, "", ServiceStack, . . , ServiceStack... . https://github.com/ServiceStack/ServiceStack/wiki/Self-hosting.

ServiceStack BL, , . ServiceStack , UserSession (https://github.com/ServiceStack/ServiceStack/wiki/Sessions). MVC- ServiceStackController, SessionFeature.GetSessionId() . ServiceStack (, Service) base.Session.

, .

+2

All Articles