asp.net-web-api

Promisifying API callbacks - How to properly resolve or reject

不打扰是莪最后的温柔 提交于 2021-02-16 21:00:35
问题 I've read similar posts, but none quite hit on the head how to do this correctly. I understand Promises and how they are typically created with success and failure listeners waiting to be triggered to either resolve or reject. What I don't understand is when I'm calling an API method that takes a success and failure callback as parameters - how do I determine which callback is being triggered so I can then have it resolved or rejected? For example with this Web API and considering the

Promisifying API callbacks - How to properly resolve or reject

大憨熊 提交于 2021-02-16 21:00:10
问题 I've read similar posts, but none quite hit on the head how to do this correctly. I understand Promises and how they are typically created with success and failure listeners waiting to be triggered to either resolve or reject. What I don't understand is when I'm calling an API method that takes a success and failure callback as parameters - how do I determine which callback is being triggered so I can then have it resolved or rejected? For example with this Web API and considering the

OAuth 2.0 Authorization for windows desktop application using HttpListener

99封情书 提交于 2021-02-11 18:22:42
问题 I am writing a windows desktop application with External Authentication(Google, Facebook) in C#. I'm using HttpListener to allow a user to get Barer token by External Authentication Service with ASP.NET Web API, but administrator privileges are required for that and I want run without admin mode. My reference was Sample Desktop Application for Windows. Is this the best practice for external authentication provider from C#? Or is there another way to do that? This is my code to get Barer token

How to get AD access token and pass it to web api controller?

孤街醉人 提交于 2021-02-11 17:43:00
问题 How to get AD access token from login.microsoftonline.com and pass access token to web api controller? as I need "access token" as such to pass on to another partner company website url via post request. Below code doing AAD authentication as expected but also I need "access token" as such, public void ConfigureServices(IServiceCollection services) { services.Configure<CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a

Controller Query Parameter (not in action)

怎甘沉沦 提交于 2021-02-11 17:01:22
问题 I'm trying to make a api like the OPENBANKPROJECT. Such as /api/banks/{BANK_ID}/atms/{ATM_ID} etc. I guess banks and atm is a different controller I want get a global ( api/Claim/{id}/Detail/[action] i need this {id}) parameter before before [action] initialize (maybe in constructor). How do i get this {id} before [action] initialize? [Route("api/Claim/{id}/Detail/[action]")] public class ClaimDetailController { int _id; // assignment {id} public ClaimDetailController(IClaimDetailService

How to set starting page or controller method of a web application when we are deploying the React or Angular or Ember applications

做~自己de王妃 提交于 2021-02-11 16:45:22
问题 I have completed a React Application, which calls a Web Api, the application runs fine with npm start, its all working fine, but when I am deploying the application, how should I set up the start page of the application, I am new to React and I have never been part of the deploying any SPA application? How can I set the start of my react application when I am going to deploy on the Server in my Website folder? Can I change it? How can I change it? When Web API is deployed separately from the

When methods have the name …Async the exception “System.InvalidOperationException: No route matches the supplied values” occurs

核能气质少年 提交于 2021-02-11 15:40:43
问题 Steps to reproduce: Create a new Web API project Create a UsersController with the following code . [ApiController] [Route("[controller]")] public class UsersController : ControllerBase { [HttpGet("{id:int}", Name = nameof(GetUserByIdAsync))] public async Task<ActionResult<object>> GetUserByIdAsync([FromRoute] int id) { object user = null; return Ok(user); } [HttpPost] public async Task<ActionResult<object>> CreateUserAsync() { object user = null; return CreatedAtAction(nameof

How can i initialize my DB connection on start of Webservice

柔情痞子 提交于 2021-02-11 14:56:36
问题 I have a Webservice written in VB.net which has several endpoints and i register the Routes in my WebApiConfig.vb. As there is no Startup page i am not sure where i can make the call on startup to initialize my db connection. 来源: https://stackoverflow.com/questions/60659630/how-can-i-initialize-my-db-connection-on-start-of-webservice

Getting error with aspnet core 2.1 action filter due to missing suitable constructor

◇◆丶佛笑我妖孽 提交于 2021-02-11 13:37:35
问题 I have made a claims filter public class ClaimRequirementAttribute : TypeFilterAttribute { public ClaimRequirementAttribute(string claimType, ClaimRoles claimValue) : base(typeof(ClaimRequirementFilter)) { Arguments = new object[] {new Claim(claimType, claimValue.ToString()) }; } } public class ClaimRequirementFilter : IAuthorizationFilter { public void OnAuthorization(AuthorizationFilterContext context) { var headers = context.HttpContext.Request.Headers; var tokenSuccess = headers

Swagger isn't working in OWIN Startup Web API C#

无人久伴 提交于 2021-02-11 12:53:28
问题 I've implemented Swagger in the OWIN startup.cs file in my Web API, but when I try to open Swagger UI page it says HTTP Error 404.0 - Not Found URL to check Swagger UI: https://localhost:5001/swagger Here is my implementation, please help me what I'm missing. Startup.cs public class Startup { public void Configuration(IAppBuilder app) { app.Map("/api", map => { ConfigureApiArea(map); }); } private void ConfigureApiArea(IAppBuilder map) { var config = CreateTypedConfiguration<BaseApiController