servicestack

Preventing StackOverflowException while serializing Entity Framework object graph into Json

两盒软妹~` 提交于 2019-11-27 21:42:11
I want to serialize an Entity Framework Self-Tracking Entities full object graph (parent + children in one to many relationships) into Json. For serializing I use ServiceStack.JsonSerializer . This is how my database looks like (for simplicity, I dropped all irrelevant fields): I fetch a full profile graph in this way: public Profile GetUserProfile(Guid userID) { using (var db = new AcmeEntities()) { return db.Profiles.Include("ProfileImages").Single(p => p.UserId == userId); } } The problem is that attempting to serialize it: Profile profile = GetUserProfile(userId); ServiceStack

Deserializing JSON that has an int as a key in C#

ぐ巨炮叔叔 提交于 2019-11-27 19:25:41
问题 I am trying to deserialize this JSON { "39": { "category": "Miscellaneous", "country_whitelist": [], "name": "domain.com", "url_blacklist": [], "country_blacklist": [], "url_whitelist": [ "domain.com" ], "deals": { "425215": { "status": "Ok", "type": "", "code": "CODE", "end_date": "2014-03-01 04:00:00", "title": "RandomTitle", "url": "http://domain.com/foo", "text": "Text Text Text", "long_title": "Longer Text" }, "425216": { "status": "Ok", "type": "", "code": "CODE2", "end_date": "2014-03

ServiceStack REST API path variables from root throwing exception

拥有回忆 提交于 2019-11-27 18:51:29
问题 I am trying to write a REST web service using ServiceStack that accepts variable paths off of route. For example: [Route("/{group}"] public class Entity : IReturn<SomeType> {} This throws a NotSupported Exception "RestPath '/{collection}' on type Entity is not supported". However, if I change the path as follows (along with the associated path in AppHost configuration) to: [Route("/rest/{group}"] It works just fine. In order to integrate with the system that I am working with, I need to use /

Enable gzip/deflate compression

北城以北 提交于 2019-11-27 18:31:37
问题 I'm using ServiceStack (version 3.9.44.0) as a Windows Service (so I'm not using IIS) and I use both its abilities both as an API and for serving web pages. However, I haven't been able to find how exactly I should enable compression when the client supports it. I imagined that ServiceStack would transparently compress data if the client's request included the Accept-Encoding:gzip,deflate header, but I'm not seeing any corresponding Content-Encoding:gzip in the returned responses. So I have a

Is it possible to serve HTML pages with ServiceStack?

心不动则不痛 提交于 2019-11-27 17:08:20
I'm evaluating ServiceStack for use in a Windows Service to host REST services. So far, it's excellent and way outperforms WCF. Not to mention its much easier to use. The Windows Services mentioned above need to be able to provide a simple HTML page to serve as a "dashboard". ServiceStack would of course be used to provide json data for the dashboard, but what about serving the dashboard page, along with images and js? Would this be possible? I would rather not host full-blown ASP.Net and have a strict limitation that IIS will never run on these servers. Scalability shouldnt be a requirement

Unit Test HTTPRequest Headers with ServiceStack

Deadly 提交于 2019-11-27 16:37:21
问题 I have this Service: public class PlayerService : Service { public IPlayerAppService PlayerAppService { get; set; } public PlayerService (IPlayerAppService service) { if (service == null) throw new ArgumentException ("Service null"); PlayerAppService = service; } public object Post (PlayerDTO request) { var newPlayer = new PlayerResponse () { Player = PlayerAppService.SendPlayerLocation(request.Position.Latitude, request.Position.Longitude) }; return new HttpResult (newPlayer) { StatusCode =

Why am I getting error “The type 'IReturn<>' is defined in an assembly that is not referenced” using ServiceStack in VIsualStudio 2017

两盒软妹~` 提交于 2019-11-27 16:25:01
I am running Visual Studio 2017 15.6.3. I have a .NET Standard 2.0 DLL project which contains Request and Response classes for use with ServiceStack. The Request classes implement IReturn<>. I have a .NET Core 2.0 console EXE project which references the .NET Standard DLL. This EXE uses a ServiceStack JsonServiceClient to send requests to a ServiceStack service. It compiles and works fine. I added a .NET Framework 4.6.1 console EXE project which also references the .NET Standard 2.0 DLL. It has to be a Framework app because it references other DLLs which are not compatible with Core or

Difference between StackExchange.Redis and ServiceStack.Redis

大兔子大兔子 提交于 2019-11-27 15:39:43
问题 Someone can explain the difference about ServiceStack.Redis and StackExchange.Redis c# libraries? 回答1: It's VERY important to notice that ServiceStack is a commercially-supported product. See the free-quotas on servicestack.net. Also this question mentions the same. The ServiceStack.Redis NuGet package include the following limitations: 10 Operations in ServiceStack (i.e. Request DTOs) 10 Tables in OrmLite 20 Different Types in JSON, JSV and CSV Serializers * 20 Different Types in Redis

ServiceStack CORS Feature

走远了吗. 提交于 2019-11-27 14:52:58
Using the new Service implementation, do I have to provide an Options method for all of my services? Using the old ServiceBase approach, which all my services currently use, OPTIONS returns OK without the Access-Control-Allow-Origin header. Here's an example: https://github.com/JonCanning/SSCors HelloService uses Service GoodbyeService uses ServiceBase mythz Because ServiceStack's Old API enforced an interface-based API it only supported GET, POST, PUT, DELETE, PATCH requests. Handling OPTION requests we're essentially a stop-gap work-around that had a single implementation to just emit the

How to use ServiceStack authentication correctly in ASP.Net MVC controller

蓝咒 提交于 2019-11-27 14:05:00
问题 I'm having problem with getting ServiceStack [Authentication] attribute to work in ASP.Net MVC4 controller, pages / action methods with the attribute keep redirecting Users to the login page even after the login details are submitted correctly. I've followed the SocialBootstrapApi example, with the difference being that all the authentication web service calls are made from the controllers: this.CreateRestClient().Post<RegistrationResponse>("/register", model); Other things that I've done so