servicestack

How to return HTTP 204 response on successful DELETE with ServiceStack

99封情书 提交于 2019-12-24 04:33:07
问题 I'm having problems returning a HTTP 204 with no body using ServiceStack If I return: return new HttpResult() { StatusCode = HttpStatusCode.NoContent }; The first time it works perfectly, but a repeated call will cause Fiddler to throw an error stating last response wasn't formed properly. I believe it is because the content type is not explicitly set to application/json , and the response comes back with an empty string or single space character. Setting ContentType = "json" on the

Best way to do property level authorization in ServiceStack?

霸气de小男生 提交于 2019-12-24 03:24:39
问题 I'm currently developing a SPA in Angular, and so I've created a REST service using ServiceStack. I am also using ServiceStack's default authentication and authorization solution, which allows me to decorate services with the Authenticate attribute, and also allows me to authorize roles. However, since my application has users, and users own resources, I need a way to restrict non-authorized users from performing certain actions. Furthermore, I would like to be able to create a single service

IReturnVoid generates exception on metadata page

三世轮回 提交于 2019-12-24 03:14:35
问题 The following DTO generates a NullReferenceException when I click on the JSON link on the metadata page. [DataContract] [Route("/AVideo")] [Route("/AVideo/{VideoID}/{Filename}")] public class PlayerVideo : IReturnVoid { [DataMember] public Guid VideoID { get; set; } [DataMember] public string Filename { get; set; } //dummy } If I change the return type to IReturn<int> , the metadata page generates correctly. 回答1: Looks like there's a pull request to fix this. 来源: https://stackoverflow.com

Set public properties in ServiceStack web services

妖精的绣舞 提交于 2019-12-24 03:01:48
问题 I am trying to write unit tests for ServiceStack services using Sqlite. Since Sqlite doesn't support stored procedures, I've created public property of type 'ServiceCommand' that takes command text and command type as inputs. By default it is configured to run stored procedure and while writing unit test cases, I am re-assigning the SelectCommand property to sql query against sqlite before calling Any() method as below. All test cases work fine. var request = new CustomerRequest() { name =

Is there any way to get ServiceStack to deserialize complex types on a Silverlight client?

只愿长相守 提交于 2019-12-24 02:45:30
问题 I want to deserialise a JSON response from a Silverlight client. I have my DTOs in a Portable Class Library, referenced from both server and client. public class MyDTOResponse { public IEnumerable<MyType> ResponseData {get; set; } } When I use the ServiceStack C# client (ie NOT from Silverlight), everything works fine: MyType gets hydrated on the client. From Silverlight, however ResponseData is null. Simple types work fine from Silverlight also. For example, this works: public class

ServiceStack ORMLite not deserializing JSON stored in DB text field

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 02:33:39
问题 I have some telemetry data that was stored in a text field as JSON. I'm attempting to reverse-engineer POCOs to seamlessly extract and present that data without having to do any post-processing ForEach loops. When I attempt to manually parse the JSON string in the data field, it works. When I am selecting via ORMLite, it comes back with the default object. What am I missing? Works string x = "{\"alive\":true,\"paperStatus\":\"0:NoIssue\"}"; var telemetry = JsonSerializer.DeserializeFromString

ServiceStack Razor - Html.RenderAction equivalent

孤者浪人 提交于 2019-12-24 02:25:06
问题 I have the requirement to use Html.RenderAction like you would in ASP.NET MVC. For instance I have a Home Page with News and Products on. I would like to do for instance @Html.RenderAction("/api/products/featured") Which would start a new service call and output the template to the html stream. Is this possible using ServiceStack Razor and if so how do I accomplish it? 回答1: The PartialExamples.cshtml test page shows different examples of rendering a razor view inside a page, e.g: Using the

Servicestack authentication process on each request

时光怂恿深爱的人放手 提交于 2019-12-24 01:44:45
问题 I have been through much of the documentation and examples provided, but Im looking for some inputs for my setup from other users. I have a some clients (website, iOs/Android apps). These only serves as a shelves and its content will be requested through servicestack, which makes servicestack a central point of my setup. The client will login through servicestack and get a sessionid. My question here is, how should i setup servicestack to make sure that the user is validated on each request?

How can I get my ServiceStack Tests to authenticate using RestSharp?

不想你离开。 提交于 2019-12-24 01:44:06
问题 I've got a working implementation of CustomCredentialsAuth implemented in my ServiceStack app. I can hit the URL with auth credentials, and it works as expected. In my tests however, I'm not having the same luck. I'm using RestSharp, and if I disable [Authenticate] , I can get all of my tests to pass. Enabling [Authenticate] and running the tests give me Expected: OK But was: Unauthorized Here is my test. How can I get RestSharp to authenticate for my tests? using System; using System.Net;

What is the point of the httponly ss-tok bearerToken cookie in ServiceStack Authentication

让人想犯罪 __ 提交于 2019-12-24 00:54:17
问题 I understand from security perspective the concept of an httponly flag for the value of Set-Cookie Response header and preventing XSS attacks. What I do not understand is, what is ServiceStack doing with the "ss-tok" cookie that saves the bearerToken. According to ServiceStack documentation I can convert to a stateless session by issuing a stateless JWT Cookie like so: var authResponse = client.Send(new Authenticate { provider = "credentials", UserName = username, Password = password,