servicestack

ServiceStack - Dependency seem's to not be Injected?

倾然丶 夕夏残阳落幕 提交于 2019-12-03 17:04:13
I have the following repository class: public class Repository<T> : IDisposable where T : new() { public IDbConnectionFactory DbFactory { get; set; } //Injected by IOC IDbConnection db; IDbConnection Db { get { return db ?? (db = DbFactory.Open()); } } public Repository() { Db.DropAndCreateTable<T>(); } public List<T> GetByIds(long[] ids) { return Db.Ids<T>(ids).ToList(); } } Then in my AppHost.Configure() . I register the dependency like so: container.Register<IDbConnectionFactory>(c => new OrmLiteConnectionFactory(ConfigurationManager. ConnectionStrings["AppDb"].ConnectionString,

ServiceStack Entities Id field name

这一生的挚爱 提交于 2019-12-03 15:51:48
I use ServiceStack and would like to store objects as hashes in Redis and get an access to their parts (fields) by ids without serializing whole object, so I have a questions: Is there a way to use other property then "Id", to mark id field? I am using naming conventions, where id field is named like "class name+Id". So in User class there will be UserId id field, in Itemclass ItemId and so on. Is the a way to update properties that were changed in the object without serializing whole object into hash and without low-level manipulations with hash command of Redis? For example, by using some

Use ASP.NET Membership in ServiceStack

≯℡__Kan透↙ 提交于 2019-12-03 15:15:11
how can i use asp.net membership in ServiceStack ? (ServiceStack.OrmLite , ServiceStack.Host.AspNet , etc ) mythz You can host ServiceStack on a custom path , i.e. at /api which lets you run ASP.NET web forms and ServiceStack side-by-side and then use the normal ASP.NET membership provider in ASP.NET. You can then share UserSessions with ServiceStack using its Session Provider, here's an example on how to instantiate a Session with MVC - you can use this same class with ASP.NET. The alternative is to forgo the ASP.NET membership provider and just stick to the built-in authentication in

Security for an AngularJs + ServiceStack App

随声附和 提交于 2019-12-03 15:04:36
问题 I have an application that have four modules in the front end, I'm trying to use as much as possible AngularJs in the front end I'm using an empty website asp.net project to host all the files and the REST serviceStack, my project have kind of the following structure: ~/ (web.config, global.asax and all the out of the box structure for an asp.net website) - App <- AngularJs - Users <- js controllers and views (static html files) - Companies - BackEnd - Public Index.html IndexCtrl.js App.js -

Timeout expired. - Using Db in ServiceStack Service

谁都会走 提交于 2019-12-03 14:22:47
I'm using the Db property in a ServiceStack service to access my database but every now and then I get the following error from IIS: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached. Stack Trace: [InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.] System.Data.ProviderBase.DbConnectionFactory

Examine Request Headers with ServiceStack

只谈情不闲聊 提交于 2019-12-03 14:16:19
What is the best way to inspect the Request Headers for a service endpoint? ContactService : Service Having read this https://github.com/ServiceStack/ServiceStack/wiki/Access-HTTP-specific-features-in-services I'm curious as to the preferred way to get to the Interface. Thank you, Stephen Inside a ServiceStack Service you can access the IHttpRequest and IHttpResponse objects with: public class ContactService : Service { public object Get(Contact request) { var headerValue = base.Request.Headers[headerKey]; //or the same thing via a more abstract (and easier to Mock): var headerValue = base

servicestack with funq - autowiring by convention

你说的曾经没有我的故事 提交于 2019-12-03 14:09:59
I have a service which takes an IMyDependency in its constructor. IMyDependency, MyDependency and the service all live in the same assembly. MyDependency has a single, public, parameterless constructor. To my surprise, this did not work: container.RegisterAutoWired<IMyDependency>(); It throws a "System.NullReferenceException". It works if I do this: container.RegisterAutoWiredAs<MyDependency, IMyDependency>(); But then, so does this: container.RegisterAs<MyDependency, IMyDependency>(); So what is the difference? If 'auto wiring' cannot find a concrete implementation, and it makes no difference

What are the benefits of async webservices when not all parts of the code is async

妖精的绣舞 提交于 2019-12-03 14:04:46
I am wondering how much benefit you get from using async http requests if not all parts of your code is async. Lets consider to scenarios: 1) async http requests blocking on sync database calls, and 2) sync http requests awaiting async database calls. 1) Web Api supports async action methods, but if I do a sync database call when handling the request, then the thread blocks on the call, and I will not get the benefits of better thread economy that async could give me or what? 2) If I have a synchronous ServiceStack service call that awaits an async database call, then what happens? I assume a

How do I redirect after authentication in ServiceStack

99封情书 提交于 2019-12-03 13:42:42
问题 I've overridden the CredentialsAuthProvider like so: public override bool TryAuthenticate(IServiceBase authService, string userName, string password) { //TODO: Auth the user and return if valid login return true; } public override void OnAuthenticated(IServiceBase authService, IAuthSession session, IOAuthTokens tokens, Dictionary<string, string> authInfo) { base.OnAuthenticated(authService, session, tokens, authInfo); //User has been authenticated //Find the user's role form the DB if (roleA)

using RavenDB with ServiceStack

心已入冬 提交于 2019-12-03 13:36:29
问题 I read this post by Phillip Haydon about how to use NHibernate/RavenDB with ServiceStack. I don't see the point about getting the IDocumentStore and open new session every time i need something from the db like this: public class FooService : ServiceBase<Foo> { public IDocumentStore RavenStore{ get; set; } protected override object Run(ProductFind request) { using (var session = RavenStore.OpenSession()) { // Do Something... return new FooResponse{/*Object init*/}; } } } Why cant i just use