servicestack

Service Stack on MVC4

扶醉桌前 提交于 2019-11-30 11:25:09
I am just trying to get Service Stack running under a mvc4 project. Does the ServiceStack.Host.Mvc nuget package work with mvc 4.0 ? I installed it and added the routes.IgnoreRoute("api/{*pathInfo}"); to the routing config but it does not find the route when I go to /api/metadata and I get the error: No HTTP resource was found that matches the request URI ' http://localhost:51681/api/metadata '. Found the solution. Whenever we are creating new asp.net mvc4 project it comes with Asp.Net Web Api. And that also having path api/. I don't you need both together, so just removed that modules using

How can i convert XSD file to C# Class

爱⌒轻易说出口 提交于 2019-11-30 10:59:29
问题 I have a file in XSD format. How can I convert it to a C# class ? I need class reference in other web applications where I need to make post call as per below: var res = client.Post<Customer>("/customers", c ); 回答1: Use the XML Schema Definition Tool xsd.exe found in your framework tools to convert your schema into a serializable class or dataset. xsd file.xsd {/classes | /dataset} [/element:element] [/language:language] [/namespace:namespace] [/outputdir:directory] [URI:uri] And in example,

ServiceStack client add attachment

*爱你&永不变心* 提交于 2019-11-30 10:13:53
I'm using ServiceStack.ServiceClient.Web.XmlServiceClient to connect to a webservice. Is there a way to add an attachment to the request? More info: What I am trying to do is avoid using Microsoft.Web.Services2 because I am using Mono. I'm trying to upload an XML datafile, along with an XML request. Just like in this question: Upload report unit via webservice in C# .net to jasperserver To upload files the best (and fastest) way is to not encode it as a normal request variable but simply upload it to the web service as a normal HTTP Upload with ContentType multipart/form-data , i.e. how HTML

Redis Expire does not work

删除回忆录丶 提交于 2019-11-30 10:01:00
I use ServiceStack.Redis (build from the latest sources: https://github.com/ServiceStack/ServiceStack.Redis/tree/master/src ). I do something like this: CacheRecord foundKey = cacheRecords.GetById(p_sParentKey); ... CacheRecord cacheRecord = cacheRecords.Store(foundKey); ... redisClient.Expire(p_sParentKey, validityPeriodInMinutes * 60); i tried to debug using Console.WriteLine(cacheRecords.GetTimeToLive(p_sParentKey)); which returns -00:00:01 . it doesnt matter which value i assign to validityPeriodInMinutes. I tried aswell Expire , ExpireAt , ExpireEntryAt , ExpireEntryIn . I also tried

How to ignore a route with self-hosted ServiceStack

冷暖自知 提交于 2019-11-30 09:36:56
I am currently working on a solution where we have a self-hosted ServiceStack layer running, but the problem is that I keep getting errors when I access it from the browser and the browser tries to get the favicon. As far as I can see there is no option of ignoring a specific route when running self-hosted? I would have imagined something like Routes.Ignore("favicon*") a bit like the Routes.Add<Foo>("/foo") in my AppHost Configure method mythz Unlike MVC which uses a Http Module to process and hijack all requests, ServiceStack is built-on ASP.NET's raw IHttpHandler interfaces. This means

ServiceStack ServerEvents authentication configuration

社会主义新天地 提交于 2019-11-30 09:27:48
问题 I'm trying to use JWT authentication with ServiceStack ServerEvents to ensure that all users are authenticated but I can't find how to configure server events to do this. I assume that this works in the default configuration since it's not mentioned in the docs how to get it working, only that it does, which would mean that something in my configuration has disabled/broken this feature but I can't work out what. On the server side the setup in Configure() is pretty simple. this.Plugins.Add(

ServiceStack MARS (Multiple Active Result Sets) using ORMLite and Output Parameters

南楼画角 提交于 2019-11-30 09:25:36
ServiceStack ORMLite is great, I've typically steered clear of the ORM mentality preferring to build databases as it makes sense to build databases instead of a 1:1 class model. That said, there are a couple of things that I seem to be running into difficulty around, I'm certain it's simply my ignorance shining through. First: Is there a way to manage multiple result sets using ORMLite? I know that one can use the QueryMultiple method using Dapper, but for whatever reason I'm having a bear of a time figuring out how to use the built-in Dapper implementation of ServiceStack. Second: Is there a

Alternative to servicestack.redis [closed]

一世执手 提交于 2019-11-30 07:50:01
I did an package manager update-package command to update our project to the latest binaries. I almost published it because it passed all the tests until luckily I had found a problem that needed some more debugging. My mouth fell open when I suddenly saw this exception message: The free-quota limit on '6000 Redis requests per hour' has been reached. Please see https://servicestack.net to upgrade to a commercial license. What if I published this site? Practices like these are simply revolting! There is no console warning or whatsoever about not having any license. It's like having an 'open

How to retrieve auto-incremented Id in ServiceStack OrmLite?

别等时光非礼了梦想. 提交于 2019-11-30 06:41:29
For a table that has an identity: [AutoIncrement] public int Id { get; set;} When inserting a new row into the database, what is the best way to retrieve the Id of the object? For example: db.Insert<> (new User()); The value of the Id is 0 after the insert, but in the database this obviously is not the case. The only possibility I can see is the following: Id = (int)db.GetLastInsertId(); However I don't believe this would be a safe call to make. If there are 100's of inserts happening at the same time, an Id for another insert may be returned. In EF when you do an insert the Id is set for you.

Custom exception handling in ServiceStack REST service

孤者浪人 提交于 2019-11-30 05:17:22
问题 I have a ServiceStack REST service and I need to implement custom error handling. I've been able to customize service errors by setting AppHostBase.ServiceExceptionHandler to a custom function. However, for other types of errors, such as validation errors, this doesn't work. How can I cover all cases? In other words, I'm trying to achieve two things: Set my own HTTP status codes for every kind of exception that might pop up, including non-service errors (validation) Return my own custom error