servicestack

ServiceStack “new” api and async await

放肆的年华 提交于 2019-12-05 08:07:51
ServiceStack version 3 I'm quite familiar with https://github.com/ServiceStack/ServiceStack/wiki/New-API and on this page it specifically says "All these APIs have async equivalents which you can use instead, when you need to." Is it possible to use async await with ServiceStack's new api? What would the server and client code look like with async await? [Route("/reqstars")] public class AllReqstars : IReturn<List<Reqstar>> { } public class ReqstarsService : Service { public List<Reqstar> Any(AllReqstars request) { return Db.Select<Reqstar>(); } } Client var client = new JsonServiceClient

ServiceStack turn on Razor intellisense support without MVC

纵然是瞬间 提交于 2019-12-05 08:01:25
I have installed SS.Razor into my test project. If i simply change default.htm -> cshtml, it works, but without vs intellisense syntax support. So the razor code is plain text black and white. I wonder how to turn on Razor without opening up the project as a .net MVC project. Thank you! EDIT ------------------------------------------ Here is my web.config (note the add extension=".cshtml" ... is there ...) <?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup,

How to serialize ExpandoObject using ServiceStack JsonSerializer?

落爺英雄遲暮 提交于 2019-12-05 06:35:06
Is it possible to get the ServiceStack JsonSerializer to serialize an ExpandoObject as a flat object rather than a dictionary? Something roughly approximate to this: {"x":"xvalue","y":"\/Date(1313966045485)\/"} I am trying to compare JSON serialization of ExpandoObject using three different systems: the .NET BCL JavaScriptSerializer, Newtonsoft JSON.NET, and ServiceStack's JSON offering. I start with a fairly simple dynamic object. dynamic test = new ExpandoObject(); test.x = "xvalue"; test.y = DateTime.Now; It seems simpler for a serializer to treat an ExpandoObject as a IDictionary<string,

Redis Pub/Sub ServiceStack, cancelling the thread

空扰寡人 提交于 2019-12-05 06:25:44
This maybe a more general threading question i'm not sure. But I've got a WPF app that subscribes to channels and listens for messages from a redis database. App.SubscriptionThread = new Thread(() => { _redisSubscription.SubscribeToChannels("ChannelA", "ChannelB"); }); App.SubscriptionThread.Start(); Once I start this I have no idea how to stop it. Things I've tried. Using the Thread.Abort . This apparently doesn't stop it, as the thread just goes into a hang then forever (no unsubscription happens). Using the _redisSubscription.UnSubscribeFromAllChannels() from the UI thread. This also causes

SSL on Service Stack

。_饼干妹妹 提交于 2019-12-05 05:27:06
Is SSL supported on Service Stack on Mono? I only have access to a mac and the instructions I found here ask you to use a windows tool to create a pvk file: http://joshua.perina.com/geo/post/using-ssl-https-with-mono-httplistener The site is hosted as a linux daemon process using an upstart script to keep the server up. I ended up writing some code in my app host to enable SSL support for Service Stack, which uses HttpListener under the covers. Here is some code that will enable SSL for Service Stack for a console application: public class AppHost : AppHostHttpListenerBase { public AppHost() :

Check authorize in SignalR attribute

左心房为你撑大大i 提交于 2019-12-05 03:28:06
i have some services on ServiceStack and use SignalR in this project. And now, i would like to secure hub connection (access only for authenticated users), but i use ServiceStack framework authentication.. (not asp.net authentication) and ServiceStack's sessions (write AuthUserId ih this session and authentication flag). So, when user trying connect to the hub -- hub must to check authentication... (yes, i can request Cookies from Hub (method OnConnected, for example), but SignalR check authentication in Authorize Attribute - and i must do it in this class (not in hub) ( http://www.asp.net

How do I secure my service using SSL for Services created using Service stack?

Deadly 提交于 2019-12-05 02:51:16
问题 I would like to secure my REST service implemented over the Service Stack, by means of X509 certificates? I will be hosting my service in a .NET application. I can build the service and it seems to work fine. Any working example using certificates would be highly appreciated. 回答1: I've been following these two examples: http://pfelix.wordpress.com/2012/02/26/enabling-https-with-self-hosted-asp-net-web-api/ http://blogs.msdn.com/b/jpsanders/archive/2009/09/29/walkthrough-using-httplistener-as

ServiceStack - Dependency seem's to not be Injected?

南笙酒味 提交于 2019-12-05 02:48:35
问题 I have the following repository class: public class Repository<T> : IDisposable where T : new() { public IDbConnectionFactory DbFactory { get; set; } //Injected by IOC IDbConnection db; IDbConnection Db { get { return db ?? (db = DbFactory.Open()); } } public Repository() { Db.DropAndCreateTable<T>(); } public List<T> GetByIds(long[] ids) { return Db.Ids<T>(ids).ToList(); } } Then in my AppHost.Configure() . I register the dependency like so: container.Register<IDbConnectionFactory>(c => new

how do I log requests and responses for debugging in servicestack

时光总嘲笑我的痴心妄想 提交于 2019-12-05 02:44:06
I would like to log the entire request & response pair for a servicestack webservice. I've looked at the response filer, however the stream exposed is read only. Have you seen ServiceStack's built-in Request Logger Plugin? It's a configurable in-memory Request Logger that maintains a log / (error responses) of the recent requests. If you would like a different behaviour, you can implement and register your own IRequestLogger , it gets called for every request. It's log method gets called for every request with the following parameters. void Log(IRequestContext requestContext, object requestDto

Using ServiceStack's Swagger Plugin, how to implement a string field with a list of preset values

可紊 提交于 2019-12-05 02:01:33
问题 I am implementing Swagger API documentation using ServiceStack's new Swagger plugin and am trying to determine how to use the "container" data type. I need to display a string field that has a list of predetermined values and other parameters that are lists of sub-objects. Unless I am missing something I believe swagger can only take a text field that you input the JSON for you list of sub-objects. I believe this code should do the trick. [ApiMember(Name = "Connections", Description = "insert