servicestack

How to Create Unique Constraint with Multiple Columns using ServiceStack.OrmLite?

假如想象 提交于 2019-12-23 20:12:38
问题 How does one create a unique constraint with ServiceStack.OrmLite (using attributes, hopefully)? The documentation shows how to create a unique constraint only on a single column: ServiceStack.OrmLite Docs If it helps, I am using ServiceStack.OrmLite.SqlServer . 回答1: Service Stack appears to have a CompositeIndex attribute which takes multiple field names. Here's a look at the constructors... CompositeIndexAttribute(params string[] fieldNames); CompositeIndexAttribute(bool unique, params

Running ServiceStack side by side with MVC

一个人想着一个人 提交于 2019-12-23 19:37:12
问题 I managed to run ServiceStack side by side with MVC4, but I still have a little problem and hope someone can help me with that. When executing a debugging session through VS2012, everthying works perfect - the browser is opened and the first page is loaded well. But then when refreshing the page, and trying to get to http://localhost:62322/Content/site.css , the following error is displayed: Handler for Request not found: Request.ApplicationPath: / Request.CurrentExecutionFilePath: /Content

ServiceStack Razor (self-hosted) with embedded images/css

半世苍凉 提交于 2019-12-23 16:55:07
问题 I have a self-hosted WebService/WebApplication using the wonderful Service Stack. My views are embedded in the DLL, and so are the images. I am using the ResourceVirtualPathProvider code from GitHub. It finds the index page and layouts correctly, but it can't find the embedded images/css (probably obviously). How would I go about configuring the Razor plugin to search the path providers. I've checked in debug mode and the path providers have found all the css and images. They're just not

How to map .NET function call to property automatically?

偶尔善良 提交于 2019-12-23 16:43:00
问题 Edit: This was originally for 1:1 mapping, but I figured out that I needed a more complicated recursive mapping so a new question was posted here: How to recursively map entity to view model with Automapper function call? I am trying to generically map an entity class function to a view model, using ServiceStack ConvertTo<> method. This maps all similar types and property names and works fine, but I want to find a way to map the result of a function to a property. Here is some code Entity

ServiceStack returning JSV instead of JSON

时光怂恿深爱的人放手 提交于 2019-12-23 15:28:08
问题 I have a service created with ServiceStack. Recently I updated the ServiceStack libraries and now I am getting JSV responses instead of JSON responses. The request looks something like: POST http://localhost/api/rest/poll/create?format=json&PollFormat=1 HTTP/1.1 Host: localhost Connection: keep-alive Content-Length: 160 Accept: */* Origin: http://localhost X-Requested-With: XMLHttpRequest User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500

How to render Markdown Text from database in a Razor view?

淺唱寂寞╮ 提交于 2019-12-23 12:45:45
问题 So I am handling my own custom Route mapping (rather than allowing ServiceStack to automatically handle it), simply because all of my data is stored inside of a database, page content and all. I have a series of _Layout.cshtml files, and my Markdown is stored as a string. So I suppose I am asking, what type of Service do I need to inherit (regular Service?) for my mapped Route, and what do I need to return to state "use Layout X and Markdown in string Y" ? I have read through the examples on

ServiceStack Custom User Authentication

假如想象 提交于 2019-12-23 10:39:32
问题 Does anyone have an actual example of how to use int RefId as proposed in this question? I am trying to get authentication going but I need to marry up the userAuth data with my own user table. The problem is I have no idea how to pass an additional parameter to the "/register" method. I guess I'm looking for an event like "OnAddUser" which will allow me to throw some additional parameters into the mix. I managed to get the user registration working pretty quickly, it was super easy. Maybe

Swagger with Service Stack not working

邮差的信 提交于 2019-12-23 10:17:57
问题 I am trying to implement Swagger with Service Stack. I've installed service stack with swagger using nuget. Current DLL versions are reported as 3.9.56.0 mostly. I am trying to follow the example provided at... https://github.com/ServiceStack/ServiceStack.UseCases/tree/master/SwaggerHelloWorld and the instrucstion appear fairly fool-proof... Plugins.Add(new ServiceStack.Api.Swagger.SwaggerFeature()); goes into the 'Configure' method after I've installed via nuget (as the documentation

Seeing the Http Response content in ServiceStack

青春壹個敷衍的年華 提交于 2019-12-23 09:57:48
问题 I am using ServiceStack to create a C# client to a JSON RESTful service. I have this code that returns my DTO: Search result = restClient.Get (search); This works fine, but in order to effectively debug the search results coming back I need to output the text content from the underlying HTTP Response object. (I don't know all the elements in the response yet in order to add them to the DTO). Is there any way I can get hold of the underlying HTTP response, and thus the full text content, from

ServiceStack JsonServiceClient - Custom HTTP Headers not sent

社会主义新天地 提交于 2019-12-23 09:27:00
问题 I'm trying to send custom HTTP Headers with a JsonServiceClient but headers are never sent in the query. I'm using: JsonServiceClient client = new JsonServiceClient (baseUri); client.Headers.Add ("X-Parse-Application-Id", "XXXXXX"); client.Headers.Add ("X-Parse-REST-API-Key", "XXXXXX"); Any idea ? 回答1: You haven't made a request yet. The Headers get added here when you make a request. An alternative way to add headers is to use the Request filters, e.g: client.RequestFilter = httpReq => {