servicestack

Razor.ServiceStack - Views not rendering, just default “Snapshot”

旧街凉风 提交于 2019-12-07 14:28:33
问题 I've setup a site using http://razor.servicestack.net/. I've created several views and matching services with an example as follows: Service Example: using ServiceStack.ServiceHost; using ServiceStack.ServiceInterface; using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace website { [DefaultView("AboutUs")] public class AboutUsService : Service { public object Get(AboutUsRequest request) { return new AboutUsResponse { //any properties that need to be

Broadcast rabbitMq messages with ServiceStack

天涯浪子 提交于 2019-12-07 13:48:09
问题 Is there way to make method myMessageService.CreateMessageQueueClient().Publish(myMessage); broadcast messages to all receivers? 回答1: The problem is, that RegisterHandler<T> internally uses the type of T to build the queue name it listens to. So the only chance you have is to go off the track with the following solution by utilizing a custom fanout exchange to multiple queues: var fanoutExchangeName = string.Concat(QueueNames.Exchange, ".", ExchangeType.Fanout); At some point of your system

with servicestack how can i prevent cookies being added to the response?

余生长醉 提交于 2019-12-07 13:46:50
问题 I can remove the cookies after the fact, with this: public override void Configure(Funq.Container container) { ResponseFilters.Add((req, res, dto) => { ((HttpListenerResponse)res.OriginalResponse).Headers.Remove("Set-Cookie"); }); } I have also considered overriding the SetCookie method of HttpResponse to just ditch the cookies, but I am not sure how to override that behaviour in servicestack. Question: How can I ensure no cookies are added to my responses in the first place? This seems more

Populating IAuthSession with data from the database

戏子无情 提交于 2019-12-07 13:30:57
问题 So I've created a custom CredentialsAuthProvider using ServiceStack as per the examples located here: https://github.com/ServiceStack/ServiceStack/wiki/Authentication-and-authorization I have the authentication side of things working but I'm not sure how I populate the session with data from the database in the OnAuthenticated method. In the example they show the following: //Fill the IAuthSession with data which you want to retrieve in the app eg: session.FirstName = "some_firstname_from_db"

How to test ServiceStack Service using Moq

安稳与你 提交于 2019-12-07 12:10:53
问题 I have a rest service that I have created with ServiceStack, using nHibernate as a way of getting the data from a SqlCe database. I've been trying to write some unit tests using nUnit and Moq - I have successfully mocked the nHibernate implementation to return null, invalid objects and so on - but my tests always throw a NullReferenceException when it calls the base class to set the HttpStatus etc. public List <ParameterDto> Get (ParameterAll parameterAll) { List <ParameterDto>

Is there a way to authorise servicestack with ASP.NET Identity?

99封情书 提交于 2019-12-07 09:26:19
问题 The only example I have found of mutual authentication between ASP.NET MVC and Servicestack involves using Servicestack's built in authentication and setting the cookie for old MVC Forms authentication. I am interested if it is possible to flip this around and authorise servicestack services with the new ASP.NET Identity system. The reason being that I would IDEALLY like to have a simple authentication story and use the same attributes, such as [Authorize] [AllowAnonymous] from Identity with

How can I overwrite Login Url in ServiceStack.MVC authentication?

亡梦爱人 提交于 2019-12-07 08:29:27
How can I override login Url? Could you add it to AuthenticateAttribute as property? When using ServiceStacks' authentication mechanism you inherit from either ServiceStackController or ServiceStackController<T> which in turn inherits the former. The login URL is dictated by the LoginRedirectUrl property of ServiceStackController . public virtual string LoginRedirectUrl { get { return "/login?redirect={0}"; } } Since it is virtual you can simply override it in your own Controller. Or even better, make your own abstract base controller that inherits from ServiceStackController . Then let all

ServiceStack JsonServiceClient based test fails, but service works in browser

风格不统一 提交于 2019-12-07 08:17:18
After I got my single-page web app working (web pages served with ServiceStack's RazorFormat() MVC, not .ASP MVC) , I ran a (previously passing) test for the service. The test failed. Tested the web app again (debug run, navigate to //localhost:1337/ResourceList in the browser) : still working. Is something wrong with my test? Here's the error: Test Name: TestResourceList Test FullName: [0-1015]ServiceWrapper.Test.TestSWrapperServices.TestResourceList Test Source: c:\Users\uname\Documents\Visual Studio 2012\Projects\ServiceWrapper\UnitTestProject1\ServiceTests.cs : line 96 Test Outcome: Failed

ServiceStack ResponseFilterAttribute not being called

大兔子大兔子 提交于 2019-12-07 08:15:28
问题 //--------------------------------------------------------------------- //Aspect Filters public class RequestAspectAttribute : RequestFilterAttribute { public RequestAspectAttribute() { } //debug point was hit public RequestAspectAttribute(ApplyTo applyTo) : base(applyTo) { } public override void Execute(IHttpRequest req, IHttpResponse res, object reqDto) { //This code is executed before the service //debug point was hit } } public class ResponseAspectAttribute : ResponseFilterAttribute {

Serializing ExpandoObject with ServiceStack.Text

浪子不回头ぞ 提交于 2019-12-07 07:39:12
问题 I am trying to serialize objects with the library ServiceStack.Text . This works using System.Dynamic; using ServiceStack.Text; var x = new {Value= 10, Product = "Apples"}; Console.WriteLine(JsonSerializer.SerializeToString(x)); I get, as I expect {"Value":10,"Product":"Apples"} However dynamic x = new ExpandoObject(); x.Value = 100; x.Product = "Apples"; Console.WriteLine(JsonSerializer.SerializeToString(x)); I get to my surprise [{"Key":"Value","Value":100},{"Key":"Product","Value":"Apples"