servicestack

How do you remove the metadata redirect in ServiceStack?

我的梦境 提交于 2019-12-10 17:57:16
问题 I have ServiceStack installed via NuGet, and I have added the following Config within SetConfig: EnableFeatures = Feature.All.Remove(Feature.Metadata) which has removed the physical page from /metadata however, each time I try to hit the root, I am still redirected to /metadata. I could not see anything else allowing me to handle this on the official page ( https://github.com/ServiceStack/ServiceStack/wiki/Metadata-page ) - any help would be highly appreciated! 回答1: You can add your own

How can I hide endpoints from Swagger UI in Servicestack?

六眼飞鱼酱① 提交于 2019-12-10 17:56:28
问题 I'm using the Swagger plugin for ServiceStack 3.9.59.0. I have a few endpoints, for example /selfchecknode, in my ServiceStack API that I don't want to show up in the Swagger UI. Is there a declarative way, perhaps via a contract attribute, that I can use to hide specific endpoints from showing up in Swagger? 回答1: The Security docs show how you can restrict visibility and access to ServiceStack. So you can hide it from being visible externally with: [Restrict(VisibleInternalOnly = true)]

How to time a request to response lifetime?

≯℡__Kan透↙ 提交于 2019-12-10 17:56:22
问题 I'm currently adding a cookie to the request object, and subtracting it from the current time in the response, but I'm assuming there's a better way to do this. Also, re-using the same Cookie key probably won't do in real use case. Any ideas? RequestFilters.Add((request, response, dto) => { request.Cookies.Add("Start", new Cookie("Start", DateTime.Now.ToString())); request.ResponseContentType = ContentType.Json; }); ResponseFilters.Add((request, response, dto) => { Console.WriteLine("{0} : [

ServiceStack authentication with MVC Controllers

本秂侑毒 提交于 2019-12-10 17:46:09
问题 I've followed the samples in SocialBootstrapAPi for ServiceStack but I don't get it how the redirects are wired up. When I go to the Secured controller being unauthenticated I get redirected back to the index page. I was unable to replicate the behaviour in my own application. Did not find where this wirings are done - can't find them in SocialBootstrapApi's web.config? I've inherited from the ServiceStackController<AuthUserSession> and put [Authenticate] on my base controller. This is the

How to change HTTP 401 response in ServiceStack?

牧云@^-^@ 提交于 2019-12-10 17:41:57
问题 By default, ServiceStack returns http status 401 when I try to call anything before authorization. How do I return http status 200 and my DTO instead of that? Ideally, I want to show boolean NeedAuth=true flag in ResponseStatus application wide, if I try calling anything unauthorized. 回答1: The 401 is written to the Response, there's no current way to undo that. If you have special requirements, you don't want to use the built-in Authentication functionality. Just create your own Request

How can I update user data form session in ServiceStack?

雨燕双飞 提交于 2019-12-10 17:08:02
问题 Very simple question: I have a session object in my Service: var session = this.GetSession(); //IAuthSession if (!session.IsAuthenticated) I can modify some values in the session class (e.g. Permissions) based on the parameters passed to the service; then I want to save them. How? The direct way of doing it: create a UserAuth object, popolate it with all the fields from IAuthSession, get the IDbConnectionFactory, save it. Surely there is a faster and better way, but I was not able to find it!

Deserialize Json Object to polymorphic C# object without typeNameHandling

你离开我真会死。 提交于 2019-12-10 16:06:38
问题 My problem is I want to deserialize a json object to a C# object, but the trick is that the C# object contains List< abstract class > and this abstract class is a super class of another 10 classes. public sealed class SearchAPIResult { public string Status; public SearchAPIQuery Query; public SearchResults Result; public SearchAPIResult() { } public SearchAPIResult(string status) { Status = status; } } and SearchAPIResult is: public sealed class SearchResults { public string TextAnswer;

Swagger not working on a self hosted ServiceStack Service

穿精又带淫゛_ 提交于 2019-12-10 15:49:16
问题 Following the code example at this URL : https://github.com/ServiceStack/ServiceStack/wiki/Self-hosting I created an empty solution, pasted the above C# code into 'program.cs' and ran the following nuget commands to get the required libraries and code files imported : Install-Package ServiceStack Install-Package ServiceStack.api.Swagger The service runs fine, the swagger meta data is delivered correctly, but when trying to visit /swagger-ui/index.html I get the error 'Handler not found' . I

ServiceStack.Text.JsonObject.Parse vs. NewtonSoft.Json.Linq.JObject.Parse for nested tree of 'dynamic' instances?

帅比萌擦擦* 提交于 2019-12-10 15:12:25
问题 I'd like to try ServiceStack's json parsing, but I've already figured out how to do something I need via Newtonsoft. Can this same thing by done via ServiceStack? I've tried with the commented out code but it gives exceptions, see below for exception details. Thanks! Josh [Test] public void TranslateFromGitHubToCommitMessage() { const string json = @" { 'commits': [ { 'author': { 'email': 'dev@null.org', 'name': 'The Null Developer' }, 'message': 'okay i give in' }, { 'author': { 'email':

Is it possible to scope ServiceStack.Text.JsConfig settings to just your library?

寵の児 提交于 2019-12-10 13:27:48
问题 I'm writing a custom library that uses ServiceStack.Text internally. Other libraries that consume mine may also use ServiceStack.Text. I want to change some JsConfig options (specifically date handling), but, like any good citizen, I don't want my modifications of those values to cause side effects for my consumer. Unfortunately JsConfig is a static class, so its settings are static, and would bleed to other consumers of ServiceStack in the same AppDomain I believe. That's an undesired