servicestack

Resolving a ServiceStack Service and defining content type

六眼飞鱼酱① 提交于 2019-12-13 00:09:28
问题 I'm currently developing a C# ServiceStack API. In one of the Services I need to execute another service. I resolve the service from the Funq container and execute the relevant method but get json returned instead of .net objects. I understand this is because the original request from the front end was for a content-type of json and the default content type is json. Is there a way I can resolve the service and execute its methods but receive .net objects instead? 回答1: You can execute and

Service stack: Difference between GetSession and SessionAs<t>

早过忘川 提交于 2019-12-12 21:25:41
问题 Are there any significant differences between Service.GetSession() and Service.SessionAs<T>() and how they resolve the sessions? I'm maintaining this code that makes use of one in some requests and uses the later in others. Are there interchangeable or are their some other considerations? 回答1: Exactly this difference public virtual IAuthSession GetSession(bool reload = false) { var req = this.Request; if (req.GetSessionId() == null) req.Response.CreateSessionIds(req); return req.GetSession

ServiceStack Handler Not Found When Periods Present in Path

吃可爱长大的小学妹 提交于 2019-12-12 20:49:15
问题 When doing a GET with an email address (periods present) in the middle of the path we are getting an error from ServiceStack saying "Handler for Request Not Found". When moving the email address portion of the route to the last section of the path it is successful. Fails "/path/to/me%40example.com/action" Success "/path/to/action/me%40example.com" We have been able to work around it by keeping the email address at the end of the path, but when there is more than one parameter with the

ServiceStack Cors

醉酒当歌 提交于 2019-12-12 19:43:03
问题 I am building a project and wish to implement CORS. It is installed on a shared IIS server (shared hosting). In my apphost.cs I enable and configure CORS according to several of the articles I find on the web. Plugins.Add(new CorsFeature( allowedMethods: "GET, POST, PUT, DELETE, OPTIONS", allowedOrigins: "*", allowCredentials: true, allowedHeaders: "content-type, Authorization, Accept")); I also read that when implementing the newer SS API (IService) I had to provide a hook for the 'Options'

How to change CacheClients at runtime in ServiceStack?

懵懂的女人 提交于 2019-12-12 19:24:36
问题 I'd like (through app/web configuration perhaps) to change the cache client used in my ServiceStack application, during runtime. For example, I have this currently: container.Register<ICacheClient>(new MemoryCacheClient()); I'd like at runtime to change this to a Redis ICacheClient usage. What if I had two containers registered (one Memory and on Redis). Is it possible to switch between containers at runtime in a call like this in my service: public object Get(FooRequest request) { string

Mono Views rendering (errors?) numbers, in IIS is ok

余生长醉 提交于 2019-12-12 18:52:24
问题 I'm running a .NET on mono 2.10, developed with ServiceStack 3.9.55 When i run the website with IIS Express everything is OK, but with mono 2.10 and fastcgi-server4 the page render extra numbers like 0 and f7e. I've already tested this o Ubuntu 12, Debian 6 and 7 and the same numbers are displayed. See it here. http://aaviseu.guilhermecardoso.pt/home What you think it may be? UPDATE: This error only appears on 2.10 and it's related with chuncked encoding (on 2x). I don't know when this was

How to ensure that ServiceStack always returns JSON?

不想你离开。 提交于 2019-12-12 17:05:18
问题 We have decided to only allow requests with a Content-Type header "application/json". So, whenever we receive a request with an alternative or missing Content-Type header, we throw an HttpError. This should return a 400 response containing a JSON ResponseStatus body with relevant info. However, if a Content-Type text/plain is sent, we throw an HttpError, but the response's Content-Type is text/plain and content-length: 0. I expected ServiceStack's ResponseStatus to be returned. The

ServiceStack.Text does not serialize my object as expected

余生长醉 提交于 2019-12-12 16:28:41
问题 I'm trying to compare performance results of serialization / deserialization using Newtonsoft.Json and ServiceStack.Text libraries. I have a large class which is named Application and I'm using an instance of this class for these operations. For the same instance NewtonSoft.Json works fine and gives me the following output: { "$id": "1", "_expiryDate": { "$id": "2", "_underlyingValue": null, "_isModified": false, "_isTrimmed": false }, "_number": { "$id": "3", "_underlyingValue": 700771, "

Date support in d.ts for servicestack typescript client

北城余情 提交于 2019-12-12 14:57:54
问题 By default servicestack typescript file dtos.ts generated by webstorm plugin makes all date properties as string. // @Required() to: string; in servicestack .cs file this property is DateTime. Any ideas why it is so and what do I need to do so it converts it to Date as asp.net web api for example 回答1: Unlike other languages, there is no "deserialization step" in TypeScript, i.e. the TypeScript DTOs just defines the Type that's returned in the raw JSON which as there's no Date type in JSON,

Multiple Nested Tables - ServiceStack Ormlite

拥有回忆 提交于 2019-12-12 14:24:27
问题 I have a set of nested tables eg. Customer -> Customer Order -> Order Details…. which Im using with service stack and ormlite... I need to be able to be able to pass in a customerid and then return a json feed with customer orders nested within the customer object and order details nested within each customer order object... struggling to acheive this. Ive seen a plural site vid that handles down to the second layer and works well eg. var customer = Db.GetByIDorDefault<Customer>(CustomerId);