asp.net-web-api

There is no implicit reference conversion from ApplicationDbContext to Microsoft.EntityFrameworkCore.DbContext

淺唱寂寞╮ 提交于 2020-01-16 18:05:26
问题 While following the tutorial, I am getting an error when DbContextOptions<ApplicationDbContext> which is ApplicationDbContext inherit to IdentityDbContext but when I tried to inherit DbContext it works fine. Error Screen Shot: Exception message: The type 'WebExtractorPortalCore.Context.ApplicationDbContext' cannot be used as type parameter 'TContext' in the generic type or method 'DbContextOptions'. There is no implicit reference conversion from 'WebExtractorPortalCore.Context

Error while calling Webapi in my asp.net project

☆樱花仙子☆ 提交于 2020-01-16 08:39:11
问题 This is my api code that return successfull json data while using get method public Question[] Get() { getQuestion obj = new AllDataAccess.getQuestion(); return obj.questionList().ToArray(); } This is my post method data that accept the value and save in database public void Post([FromBody] string question) { SaveQuestion obj = new AllDataAccess.controller.SaveQuestion(); obj.savaData(question); } This is the method that call my api $.ajax({ type: 'POST', contentType: "application/json;

Azure AD Auth with Angular and .NETCore2 WEBAPI

青春壹個敷衍的年華 提交于 2020-01-16 08:35:28
问题 I want to add authentication to my app using Azure AD Right now my flow is like User -> AngularApp -> Azure Login -> AngularApp w/token -> API Call to backend w/token -> API Backend verifies token with Azure each call I have following questions: Is there a better way to do this? Every API call is verified with azure. Is is required? Should i have two different client id for UI and API? 回答1: Is there a better way to do this? This is the standard way. Every API call is verified with azure. Is

MultipartFormDataStreamProvider and preserving current HttpContext

别说谁变了你拦得住时间么 提交于 2020-01-16 07:05:54
问题 I have a problem with the async file uploading feature of WebApi. Currently I am able to save the file using the provider, but I then want to use a service (_myService) to log the filename of the file uploaded. Inside the service, it uses another service to get the current UserId. It does this by using the current HttpContext. Unfortunately the current HttpContext seems to be lost within the new task thread. I tried to add TaskScheduler.FromCurrentSynchronizationContext() as the 2nd parameter

ASP.NET Web API 2 - POST / jQuery

时光毁灭记忆、已成空白 提交于 2020-01-16 05:51:12
问题 I am trying to post an object to the server where I am using Web API 2. The code as follows: $.ajax({ cache: false, type: "POST", url: "/api/Employees", data: { EmployeeId: 1 }, success: function(result) { console.log("employees saved successfully"); }, error: function(result) { } }); As for the Web API: public class EmployeesController : ApiController { // POST api/<controller> public void Post([FromBody]Employee value) { } } public class Employee { public Int32 EmployeeId { get; set; }

Does returning IHttpActionResult stop request execution

拜拜、爱过 提交于 2020-01-16 05:47:47
问题 Here @GlennBlock mentioned that throwing HttpResponseException immediately stops request execution while returning HttpResponseMessage does not stop request propagation (as I understood it). The exception is useful to immediately stop processing and exit. If instead I return HttpResponseMessage, the request will happily continue the rest of it's processing and return a 404. The main difference being end the request or not. In .NET Web API 2 you can also return IHttpActionResult from

No data displayed only brackets in web API C#

旧城冷巷雨未停 提交于 2020-01-16 05:47:10
问题 I'm quite new to Web API in C#. This is my JSON response: { "<chart_type>": [ { "name": "entity" }, { "display_name": "entity display name" }, { "kpi": [ { "name":"<kpi>", "display_name":"test", "required": [ { "test": "test" }, { "test1": "test" } ], "optional": [ { "test": "test" }, { "test": "test" } ], "objects": { "<Fieldname>": { "display_name":"<entity display name>", "type": "<select or text>", "default": "default value (already selected)", "list": { "<id>": "<value>" } } } } ] } ] }

ASP.NET MVC 5 vs ASP.NET WebAPI for iOS Apps, Andoir Apps and WebApps [closed]

亡梦爱人 提交于 2020-01-16 02:25:13
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago . I need to design a customers server architecture using the .NET framework. In the future the customer will implement several clients like native Android or iOS Apps or normal Web Apps written in HTML, CSS and JavaScript (AngularJS). With which of the following approaches can

Web API performance issues with large dynamic XML

二次信任 提交于 2020-01-16 01:11:07
问题 I’ve created an WebAPI sql interface so that development users can dynamically query a database through a RESTful interface. It’s fast for small queries but when larger ones come into play there are serious lag problems especially when multiple simultaneous calls are made. I’ve run performance analysis on this and overwhelming majority of the processing is done on the line: var xe = reader.ReadOuterXml(); The clients are expecting XML text strings so I’ve tried to just do an ExecuteReader but

WebApi controller isn't found

◇◆丶佛笑我妖孽 提交于 2020-01-16 01:10:32
问题 I have an example controller in my WebApi-project: public class MilestonesController : ApiController { // GET api/milestones public IEnumerable<string> Get() { return new string[] { "M#1", "M#2" }; } // GET api/milestones/5 public string Get(int id) { return "M with {id}"; } // POST api/milestones public void Post([FromBody]string value) { } // PUT api/milestones/5 public void Put(int id, [FromBody]string value) { } // DELETE api/milestones/5 public void Delete(int id) { } } If I try to