servicestack

servicestack AppHostHttpListenerBase handlerpath parameter not working?

末鹿安然 提交于 2019-12-21 21:43:54
问题 not sure if I am missing something here. I am using the AppHostHttpListenerBase in a unit test to test a service and in its constructor I pass "api" for the handlerPath parameter. I have a service registered at /hello/{Name} and am using version 3.9.17 of servicestack. Within the Config method of my appHost class if I access EndpointHostConfig.Instance.ServiceStackHandlerFactoryPath it retrurns "api" Once I am back in the unit test the same call returns null If I try and call the service with

Translate a List<TypeA> to List<TypeB>

这一生的挚爱 提交于 2019-12-21 21:25:05
问题 Understood the concept of translate. Used it in converting a DataModel Type to DTO type for presentation layer like this and worked fine. objTypeB = objTypeA.TranslateTo<clsTypeB>(); Discrepancy between TypeA and TypeB was just the datatype of few properties and I converted them in the Property Set method. But in the above implementation if the source is List<TypeA> , I have loop through each to translate to TypeB and add it another List<TypeB> instance. Is it possible to do something like

AJAX call against REST endpoint secured with Thinktecture's IdentityServer STS

我与影子孤独终老i 提交于 2019-12-21 19:42:28
问题 I'm having some dramas making a call against a ServiceStack REST service which I've secured with an out of the box IdentityServer STS. I'm making an AJAX call against the REST endpoint, and I'm not sure how one might setup a logon procedure to get a security token to pass. The REST endpoint is on a different domain than the website making the call. The info that I've found so far all seems to revolve around the procedure where the client makes a call to the secured resource gets a 302

Is F# aware of its discriminated unions' compiled forms?

狂风中的少年 提交于 2019-12-21 08:23:06
问题 A discriminated union in F# is compiled to an abstract class and its options become nested concrete classes. type DU = A | B DU is abstract while DU.A and DU.B are concrete. With ServiceStack, the serialization of types to JSON strings and back can be customized with functions. With respect to the DU type, here's how I could do it in C#. using ServiceStack.Text; JsConfig<DU.A>.SerializeFn = v => "A"; // Func<DU.A, String> JsConfig<DU.B>.SerializeFn = v => "B"; // Func<DU.B, String> JsConfig

Is F# aware of its discriminated unions' compiled forms?

喜你入骨 提交于 2019-12-21 08:23:05
问题 A discriminated union in F# is compiled to an abstract class and its options become nested concrete classes. type DU = A | B DU is abstract while DU.A and DU.B are concrete. With ServiceStack, the serialization of types to JSON strings and back can be customized with functions. With respect to the DU type, here's how I could do it in C#. using ServiceStack.Text; JsConfig<DU.A>.SerializeFn = v => "A"; // Func<DU.A, String> JsConfig<DU.B>.SerializeFn = v => "B"; // Func<DU.B, String> JsConfig

Serialize C# Enum Definition to Json

懵懂的女人 提交于 2019-12-21 06:51:04
问题 Given the following in C#: [Flags] public enum MyFlags { None = 0, First = 1 << 0, Second = 1 << 1, Third = 1 << 2, Fourth = 1 << 3 } Are there any existing methods in ServiceStack.Text for serializing to the following JSON? { "MyFlags": { "None": 0, "First": 1, "Second": 2, "Third": 4, "Fourth": 8 } } Currently I'm using the routine below, are there better ways to do this? public static string ToJson(this Type type) { var stringBuilder = new StringBuilder(); Array values = Enum.GetValues

Timeout expired. - Using Db in ServiceStack Service

◇◆丶佛笑我妖孽 提交于 2019-12-21 04:59:16
问题 I'm using the Db property in a ServiceStack service to access my database but every now and then I get the following error from IIS: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Stack Trace: [InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled

Can't get ServiceStack to work in IIS6 with HTTPS

家住魔仙堡 提交于 2019-12-21 02:02:07
问题 I'm having a problem getting ServiceStack to work with HTTPS in IIS6 and I can't seem to find any documentation on setting this up. Currently I have an endpoint setup like so - http://example.com/api.ashx. When I browse to this, i get the useful ServiceStack generated page which explains the APIs available at http://example.com/api.ashx/metadata. When i browse to https://example.com/api.ashx (notice https) i instead get this error message - Server Error in '/' Application. The resource cannot

Does ServiceStack support reverse routing?

◇◆丶佛笑我妖孽 提交于 2019-12-21 01:06:57
问题 Following REST it is advisable that API is discoverable and should be interlinked. Does ServiceStack support any kind of reverse routing? I'm looking for something like Url.RouteLink in ASP MVC. 回答1: There's some mixed concepts stated here. In and effort of trying to comply with REST you wish to embed URI's in your responses. How best to achieve embedding URI's in your responses. You've assumed a "Reverse Routing" mechanism is how this should be done. REST style vs Strong-typing I want to be

How to unit test ServiceStack?

北战南征 提交于 2019-12-20 18:44:32
问题 I love SS but I'm scratching my head trying to unit test my business layer. I'm new to unit testing andmocking and been reading up on NSubstitute as this looks like a fun mocking layer. I have my file structure roughly like this: MainAppHostProject* | -AppStart -AppHost <-- standard apphost DtoProject* | -HelloWorldDto <-- simple POCO to ServiceLayerProject* | -HelloWorldService <-- service interface that merely passes/sends Dtos to/from business layer BusinessLayerProject* |