How to get HttpContext in servicestack.net -
i unable switch of service stack's new providers, authentication, etc. so, running hybrid scenario , works great.
to current user in service, this:
private iprincipal currentuser() { var context = httpcontext.current; if (context != null) { var user = context.user; if (user != null) { if (!user.identity.isauthenticated) return null; return user; } } return null; }
is there alternative/better way current http context directly service? prefer not have use httpcontext.current if not have to?
this alternative way... goes through servicestack originalrequest
asp.net request (though httplistener httprequest if not used within asp.net application). not sure if it's better no longer have httpcontext.current within service code.
public class myservice : service { public object get(myrequest request) { var originalrequest = this.request.originalrequest system.web.httprequest; var user = originalrequest.requestcontext.httpcontext.user; // more code... } }
Comments
Post a Comment