servicestack

ServiceStack Razor Authentication

本小妞迷上赌 提交于 2019-11-30 03:55:48
问题 I am looking at the Rockstars example and ServiceStack.Razor. How do I go about fitting authentication into, say, secure.cshtml page. So I can redirect user to Login.cshtml if required. I only understand from SocialBootstrapApi example if I mix MVC hybird, I can put [authenticate()] at ServiceStackController to achieve that. But what if I just want a pure SS project without .net MVC? 回答1: The Authenticate attribute is just a plain ServiceStack Request Filter Attribute, i.e. it works in both

ServiceStack with IIS 7.5

流过昼夜 提交于 2019-11-30 03:17:55
问题 I installed Clean Windows Web Server 2008 R2 64-bit with IIS 7.5. I created .NET v4.0 application pool and Web Site in this pool, where I deployed my application with ServiceStack services. I got this error message in web browser when I opened servicestack page.: HTTP Error 500.21 - Internal Server Error Handler "ServiceStack.Factory" has a bad module "ManagedPipelineHandler" in its module list. My application is working in Visual studio hosted IIS server. Can be problem with IIS 7.5

Using ServiceStack.Text to deserialize a json string to object

房东的猫 提交于 2019-11-30 02:57:18
问题 I have a JSON string that looks like: "{\"Id\":\"fb1d17c7298c448cb7b91ab7041e9ff6\",\"Name\":\"John\",\"DateOfBirth\":\"\\/Date(317433600000-0000)\\/\"}" I'm trying to deserialize it to object (I'm implementing a caching interface) The trouble I'm having is when I use JsonSerializer.DeserializeFromString<object>(jsonString); It's coming back as "{Id:6ed7a388b1ac4b528f565f4edf09ba2a,Name:John,DateOfBirth:/Date(317433600000-0000)/}" Is that right? I can't assert on anything... I also can't use

ServiceStack OAuth - registration instead login

偶尔善良 提交于 2019-11-29 23:27:55
问题 In servicestack OAuth implementation I only saw possibility to automatically login with eg. facebook account. But is there abbility to support registration process with facebook login. What I wanted is to let users login to facebook app, and then load their Name, Surname and email and prefill needed text boxes for real registration on my site (since I also have to have mobile phone verification etc.) I don't want user to be authorized and authenticated when he logs in with facebook. Only

How to get Swagger to send API key as a http instead of in the URL

北慕城南 提交于 2019-11-29 23:06:09
I am using swagger with servicestack but I am getting a 401 unauthorised error from my /resources URL becuase it requires an API key. Unless I'm mistaken, according to the documentation I should set supportHeaderParams to true as well as the apiKeyName and apiKey value in the JSON parameters when initializing Swagger from my html page. I was then expecting to see my API key in the http request headers, but it is still being appended to the URL and not in the headers collection. Here is the code that initialises Swagger in my HTML page: window.swaggerUi = new SwaggerUi({ discoveryUrl: "http:/

How to do token based auth using ServiceStack

泪湿孤枕 提交于 2019-11-29 22:35:40
问题 How would I implement the following scenario using ServiceStack? Initial request goes to http://localhost/auth having an Authorization header defined like this: Authorization: Basic skdjflsdkfj= The IAuthProvider implementation validates against a user store and returns a session token as a response body (JSON). The client uses this token an resends it against the subsequent requests like http://localhost/json/reply/orders using the Authorization header like this: Authorization: BasicToken

Catching exceptions with servicestack

匆匆过客 提交于 2019-11-29 22:29:47
问题 We have been using ServiceStack for REST based services for a while now and so far it has been amazing. All of our services have been written as: public class MyRestService : RestService<RestServiceDto> { public override object OnGet(RestServiceDto request) { } } For each DTO we have Response equivalent object: public class RestServiceDto { public ResponseStatus ResponseStatus {get;set;} } which handles all the exceptions should they get thrown. What I noticed is if an exception is thrown in

Html5 pushstate Urls on ServiceStack

放肆的年华 提交于 2019-11-29 22:07:36
问题 At the moment we're using a default.cshtml view in the root of ServiceStack to serve our AngularJS single-page app. What I'd like to do is enable support for html5 pushstate (so no hash in the URL), but the only examples I've found so far involve a dependency on MVC with a wildcard route, and pushing the ServiceStack infrastructure to a /api subroute. We can't take the MVC dependency, so I think we need for accept:text/html requests we need to accept any url and serve up our root application.

What's the current best solution for generating HTML from ASP.NET Razor templates within a Console Application?

随声附和 提交于 2019-11-29 19:57:24
I want to do this: string template = "Hello @Model.Name! Welcome to Razor!"; string result = Razor.Parse(template, new { Name = "World" }); And it appears that http://razorengine.codeplex.com is perfect, except it's a year old. EDIT: Turns out that RazorEngine has moved to GitHub and had a commit a few months back: https://github.com/Antaris/RazorEngine I noticed that Service Stack has some Razor self-hosting but while there's a long page here http://razor.servicestack.net there's no "hello world you can totally do this from a console." What's the current best solution for generating HTML from

Return a custom auth response object from ServiceStack authentication

孤人 提交于 2019-11-29 18:23:11
问题 Is it possible to return a custom auth response? I already have my own custom authentication provider that inherits from CredentialsAuthProvider. I want to return the session expiry date in the response, so that the client knows exactly when their server session will expire: { "sessionId": "bG27SdxbRkqJqU6xv/gvBw==", "userName": "joe.bloggs@letmein.com", "sessionExpires": "2013-04-29T03:27:14.0000000", "responseStatus": {} } I can override the Authenticate method like so: public override