servicestack

ServiceStack: How to make InMemoryTransientMessageService run in a background

随声附和 提交于 2019-12-10 07:09:09
问题 What needs to be done to make InMemoryTransientMessageService run in a background thread? I publish things inside a service using base.MessageProducer.Publish(new RequestDto()); and they are exececuted immediately inside the service-request. The project is self-hosted. Here is a quick unit test showing the blocking of the current request instead of deferring it to the background: https://gist.github.com/lmcnearney/5407097 回答1: There is nothing out of the box. You would have to build your own.

How can I mock ServiceStack IHttpRequest

大城市里の小女人 提交于 2019-12-10 06:31:37
问题 I'm trying to get a unit test working for a service that is injecting items into the IHttpRequest.Items, using a request filter: this.RequestFilters.Add((req, res, dto) => { // simplified for readability... var repo = container.Resolve<IClientRepository>(); var apiKey = req.Headers["ApiKey"]; // lookup account code from api key var accountcode = repo.GetByApiKey(apiKey); req.Items.Add("AccountCode", accountCode); }); My service uses that dictionary item: public class UserService :

Serving a static file with servicestack

99封情书 提交于 2019-12-10 06:13:43
问题 How would i go around serving a static file using servicestack? I would like to add a route like Routes.Add(/app) and when a client issues a GET for this path i need to return the a silverlight xap file. 回答1: ServiceStack is already be able to serve static files by referencing them directly. Otherwise if you want a service return a file for downloading, you can do so with: return new HttpResult(new FileInfo("~/app.xap"), asAttachment:true) { ContentType = "application/x-silverlight-app" };

What's the best way to convey required/optional DTO properties in ServiceStack?

心不动则不痛 提交于 2019-12-10 04:29:37
问题 I'm having an issue with my ServiceStack w/ Swagger implementation regarding documenting required/optional properties. Developers implementing clients that consume my services love the Swagger documentation, however they don't know which properties are required vs. optional--aside from getting a 400 response on each attempt to get a valid request through. Take the following example: public class UserProfile { public string FirstName { get; set; } public string LastName { get; set; } public

How to logout authenticated user in ServiceStack?

落爺英雄遲暮 提交于 2019-12-10 01:48:07
问题 Apologize for the noob question. Just beginning to learn servicestack. I'm using a self-hosted console application with Razor for my view engine, the "RegistrationFeature" plugin for registrations and CredentialsAuthProvider for authentication via form post to allow users to login. The SocialBootStrap application uses MVC 3 and does a "FormsAuthentication.SignOut()" to allow users to logout. Given that I'm using a self hosted application, I created a LogoutService that simply does a Request

How to pipeline multiple read commands to Redis using ServiceStack

ε祈祈猫儿з 提交于 2019-12-09 20:35:10
问题 Using ServiceStack, is there a way to perform multiple read commands (in particular the ContainsKey command)? The objects stored take a while to fetch from the database, so we're looking to get only the ones that are not in cache. I know that I can ask redis for the object and then fetch from the database if it comes back null, but the objects being stored are fairly large, so I'd rather just get a list of bools back and then determine which ids to query in the database from that. For the

Why ServiceStack.Text doesn't default dates to iso8601?

纵饮孤独 提交于 2019-12-09 14:05:34
问题 If I use Newtonsoft.Json.NET it defaults to iso8601 (i.e.: 2011-06-02T09:34:29+02:00 ) for serializing/deserializing dates. Why ServiceStack.Text doesn't default to this and I need to specify it as a configuration setting? 回答1: ServiceStack followed the .NET DataContractSerializer defaults, not JSON.NET. We are reluctant to make breaking changes like this, especially when there's an easy way to configure it otherwise with: JsConfig.DateHandler = DateHandler.ISO8601; 来源: https://stackoverflow

servicestack with funq - autowiring by convention

那年仲夏 提交于 2019-12-09 11:44:56
问题 I have a service which takes an IMyDependency in its constructor. IMyDependency, MyDependency and the service all live in the same assembly. MyDependency has a single, public, parameterless constructor. To my surprise, this did not work: container.RegisterAutoWired<IMyDependency>(); It throws a "System.NullReferenceException". It works if I do this: container.RegisterAutoWiredAs<MyDependency, IMyDependency>(); But then, so does this: container.RegisterAs<MyDependency, IMyDependency>(); So

ServiceStack - Using gzip/deflate compression with JSONP requests

回眸只為那壹抹淺笑 提交于 2019-12-09 11:32:42
问题 I have a ServiceStack service that compresses the response using RequestContext.ToOptimizedResult() , e.g.: [Route("/numbers/search")] public class FindNumbers { } public object Get(FindNumbers query) { var data = new List<string> { "One", "Two", "Three" }; return RequestContext.ToOptimizedResult(data); } This works perfectly when issuing a request like: GET http://myhost:13487/numbers/search.json And is compressed as expected with the Accept-Encoding request header: Accept-Encoding: gzip

Use asp.net authentication with servicestack

Deadly 提交于 2019-12-09 06:51:51
问题 I have written a couple of ms lightswitch applications with forms authentication -> this creates aspnet_* tables in sql server. How can I use the defined users, passwords, maybe even memberships, roles and application rights in a servicestack - application? 回答1: I have not tested this but I think it should get you started. Gladly stand corrected on any of my steps. Things I think you will need to do.. In order to Authenticate against both 'systems' you'll need to set the Forms cookie and save