asp.net-web-api

Confusion over LOCAL AUTHORITY claims and External Provider claims

倖福魔咒の 提交于 2020-01-14 09:59:06
问题 I am creating a simple WebApi which allows users to connect with Facebook. When I get the accessToken back from facebook, I am calling RegisterExternal to create an Asp.Net Identity record and store the Claims from the token. These claims also include the access token which I require to query the facebook graph later. All seems fine up to this point. The issue I am having is reading the claims. I can see they are in my database I just cant figure out how to query this data. I have tried var

Consuming ASP.NET Web Api service from other computer in LAN

让人想犯罪 __ 提交于 2020-01-14 09:33:07
问题 I googled about this, but could't find anything which will fix my problem. (I'm new to ASP.NET Web Api) I built an ASP.NET Web Api and when I run it from visual studio on the local machine everthing is working perfect. (in both cases it work fine, when I use "Use Visual Studio Development Server" and also "Use Local IIS Web server"). The problem is when I tried to call this web service from other computer in the lan network it didn't worked (somthing like: "http://192.168.2.103:8080/api

OData Doesn't Recognize My Collection Properties

早过忘川 提交于 2020-01-14 09:22:26
问题 When I post a ShakeoutDocument without the collections populated, the OData Serializer understands the JSON & populates the ODataActionParameters correctly. However, when I add a child-record into either of the ShakeoutDocument's collection properties...the Odata Controller's ODataActionParameters parameter is null. I have narrowed it down to the OData EDM Model Configuration . How do I correctly "characterize" the collection properties (below) to the EDM Model Configuration THE CLASS LOOKS

Query with OData without exposing ORM models?

北城余情 提交于 2020-01-14 08:55:08
问题 In my web api 2 project, if I want to use OData library (which looks awesome and very tempting) for queries over some properties, that would force the client side to know the exact properties of my database models. Is this a good practice? Is there a way to avoid this decouple? For the following models: public class LetterEntity { public int Id {get; set;} public string Title {get; set;} public string Content {get; set;} public string Source {get; set;} public DateTime SendingTime {get; set;}

How to update AutoRest in visual studio 2017

我怕爱的太早我们不能终老 提交于 2020-01-14 08:50:31
问题 Context I would like to use AutoRest generated client for a webapi service by using "Add"/"REST API Client..." in visual studio 2017. However, it gives the following error: [Info] AutoRest Core 0.16.0.0 ... [Fatal]Error generating client model: Collection format "multi" is not supported (in parameter 'xxx'). The older version of AutoRest (e.g. 0.16.0) does not support "multi" collection format. So I installed the latest version AutoRest 0.17.3. using Nuget. But when I use "Add"/"REST API

Set one ProducesResponseType typeof for several HttpStatusCodes

心已入冬 提交于 2020-01-14 08:32:35
问题 I am setting the ProducesResponseType so as to have it documented with Swagger. If the response is succesful (OK => 200), then it produces a IEnumerable. [ProducesResponseType(typeof(IEnumerable<MyModel>), 200)] But when I get an exception, I catch it, and then generate an object of my custom APIError class. When I populate the object, I can set different HttpStatusCodes, but in the end, what I want is to be able to set that ProducesResponseType is my APIError class for all the remaining

Set one ProducesResponseType typeof for several HttpStatusCodes

China☆狼群 提交于 2020-01-14 08:32:12
问题 I am setting the ProducesResponseType so as to have it documented with Swagger. If the response is succesful (OK => 200), then it produces a IEnumerable. [ProducesResponseType(typeof(IEnumerable<MyModel>), 200)] But when I get an exception, I catch it, and then generate an object of my custom APIError class. When I populate the object, I can set different HttpStatusCodes, but in the end, what I want is to be able to set that ProducesResponseType is my APIError class for all the remaining

Set one ProducesResponseType typeof for several HttpStatusCodes

巧了我就是萌 提交于 2020-01-14 08:32:03
问题 I am setting the ProducesResponseType so as to have it documented with Swagger. If the response is succesful (OK => 200), then it produces a IEnumerable. [ProducesResponseType(typeof(IEnumerable<MyModel>), 200)] But when I get an exception, I catch it, and then generate an object of my custom APIError class. When I populate the object, I can set different HttpStatusCodes, but in the end, what I want is to be able to set that ProducesResponseType is my APIError class for all the remaining

How to setup Request.Header in FakeHttpContext for Unit Testing

别等时光非礼了梦想. 提交于 2020-01-14 07:58:06
问题 I have a FakeHttpContext I have been trying to modify to include some headers for testing purposes public static HttpContext FakeHttpContext() { var httpRequest = new HttpRequest("", "http://stackoverflow/", ""); var stringWriter = new StringWriter(); var httpResponse = new HttpResponse(stringWriter); var httpContext = new HttpContext(httpRequest, httpResponse); var sessionContainer = new HttpSessionStateContainer("id", new SessionStateItemCollection(), new HttpStaticObjectsCollection(), 10,

How to read/parse Content from OkNegotiatedContentResult?

我的未来我决定 提交于 2020-01-14 07:17:04
问题 In one of my API actions ( PostOrder ) I may be consuming another action in the API ( CancelOrder ). Both return a JSON formatted ResultOrderDTO type, set as a ResponseTypeAttribute for both actions, which looks like this: public class ResultOrderDTO { public int Id { get; set; } public OrderStatus StatusCode { get; set; } public string Status { get; set; } public string Description { get; set; } public string PaymentCode { get; set; } public List<string> Issues { get; set; } } What I need is