servicestack

Modeling editable lists in DTOs used by services

落爺英雄遲暮 提交于 2019-12-31 04:17:07
问题 Say you have the following Contact DTO. Address/PhoneNumber/EmailAddress/WebSiteAddress classes are simple DTOs as well (just data no behavior) public class Contact { public Address[] Addresses { get; set; } public PhoneNumber[] PhoneNumbers { get; set; } public EmailAddress[] EmailAddresses { get; set; } public WebSiteAddress[] WebSiteAddresses { get; set; } } How should I model DTOs to allow implementing the following behavior? The client can submit a request that will add a phone number,

Setting up Web.config to work Side-by-Side with ASP.NET MVC 4 - Location Tag not resolving value “api”

大兔子大兔子 提交于 2019-12-30 11:39:42
问题 I checked out Run servicestack side by side with another web framework. When I add the location tag the "api" is unresolved...what do I need to do to get the location tag to be aware of "api"? 回答1: Firstly make sure you follow the README.txt instructions for running ServiceStack in ASP.NET MVC. ServiceStack automatically infers the handler path based on the <location> tag, if there's more than one or it has some other issue inferring, it can be explicitly set in Config

Validate a string to be json or not in asp.net

陌路散爱 提交于 2019-12-30 09:01:48
问题 is there any way to validate a string to be json or not ? other than try/catch . I'm using ServiceStack Json Serializer and couldn't find a method related to validation . 回答1: Probably the quickest and dirtiest way is to check if the string starts with '{' : public static bool IsJson(string input){ input = input.Trim(); return input.StartsWith("{") && input.EndsWith("}") || input.StartsWith("[") && input.EndsWith("]"); } Another option is that you could try using the JavascriptSerializer

Migrated web service to .NET Core 2.0 and returning json

谁说我不能喝 提交于 2019-12-30 07:32:13
问题 I have migrated my web service to .NET Core 2.0, it works fine but I have problem with getting response as json string. Method on api: [HttpGet] [ProducesResponseType(typeof(string), 200)] [ProducesResponseType(typeof(EntityNotFoundErrorResult), 404)] public async Task<IActionResult> GetCurrenciesAsync() { var result = await service.GetByTypeAsync(ObjectType.Currency.ToString()); return Ok(result); } that is returning proper json as result : "{\"elements\": [{\"Id\": \"1\", \"Symbol\": \"PLN\

In what order are the ServiceStack examples supposed to be grokked?

折月煮酒 提交于 2019-12-29 10:12:06
问题 Just out of curiosity I like to know the preferred ordering, based on technical level and new api of the examples. For the most part, all the base infrastructure concerns all smell the same i.e. setup of the host ect.. but when it comes to the Service Models, Service Interface, and Endpoint setup, which are the most current and preferred? Thank you, Stephen 回答1: ServiceStack example projects aren't supposed to be consumed in any particular order, they're just different examples illustrating

ServiceExceptionHandler usage on RestServiceBase<T>

假如想象 提交于 2019-12-29 07:53:28
问题 I'm trying to use the ServiceExceptionHandler on my Serivce which extends RestServiceBase<TViewModel> I can use the AppHost.ServiceExceptionHandler , that's working fine. I need the user info from the HttpRequest , thats not available at AppHost level. So I'm trying to use the ServiceExceptionHandler on Service level. Though I set the delegate on service ctor , it's null when exception thrown on OnGet method public class StudentService : RestServiceBase<Student> { public StudentService() {

Many to many relations with ServiceStack.OrmLite

孤者浪人 提交于 2019-12-29 04:58:05
问题 I've been checking ServiceStack's documentation, but I haven't found a way to do many to many relationships with ServiceStack.OrmLite, is it supported? Is there a workaround (without writing raw sql)? I'd like to have something like this: Article <- ArticleToTag -> Tag Thanks!! 回答1: It's not implicitly handled automatically for you behind the scenes if that's what you mean? But as OrmLite is just a thin wrapper around ADO.NET interfaces anything is possible. In OrmLite, by default every POCO

ServiceStack.OrmLite - how to include field from foreign key lookup?

偶尔善良 提交于 2019-12-28 12:43:22
问题 I'm trying out the ServiceStack MVC PowerPack, and am trying the included OrmLite ORM and am trying to get data from a table referenced by a foreign key without any idea how to do so. In the OrmLite examples that use the Northwind database, for example, would it be possible to return a Shipper object that included the "ShipperTypeName" as a string looked up through the foreign key "ShipperTypeID"? From http://www.servicestack.net/docs/ormlite/ormlite-overview, I'd like to add the ShipperName

What is the best way to run ServiceStack on Linux / Mono?

北战南征 提交于 2019-12-28 02:20:25
问题 Listed on the ServiceStack website it shows that ServiceStack can run on Mono with either: XSP mod_mono FastCgi Console What are these different configurations and which is preferred for Web Services on Mono? 回答1: Update for Linux From the v4.5.2 Release ServiceStack now supports .NET Core which offers significant performance and stability improvements over Mono that’s derived from a shared cross-platform code-base and supported by Microsoft's well-resourced, active and responsive team. If

Servicestack with Razor not working -> FORBIDDEN ressource

让人想犯罪 __ 提交于 2019-12-25 07:25:54
问题 I'm loosing my mind ... wanna use SS Razor feature in an empty web application on my Win 8.1 machine. Installed via NuGet, added a webpage at the root and get this error: >Forbidden >Request.HttpMethod: GET >Request.PathInfo: /default.cshtml >Request.QueryString: >Request.RawUrl: /default.cshtml >App.DebugLastHandlerArgs: >GET|/default.cshtml|Z:\GIT\MasterThesis\src\AppBlue\AppBlue.Web\default.cshtml I also tried the Razor rockstars sample app from SS - this works perfectly. So I've copied