asp.net-core-webapi

Can't send Post Data from Ajax to asp.net core web api?

北战南征 提交于 2021-01-29 09:47:28
问题 I need to send an ajax request to a post method defined in my asp.net core web api as below : // POST: api/Entreprise/Inscription [HttpPost("Inscription")] public IActionResult Post([FromBody] UserInfos value) { return Ok("value 1"); } and this is UserInfos model: public class UserInfos { public string firstname { get; set; } public string lastname { get; set; } public string email { get; set; } public string domainName { get; set; } public string phoneNumber {get;set;} public string address

Azure AD Multi Tenant ,.Net Core Web API with MSAL(Microsoft Authentication Libary)

非 Y 不嫁゛ 提交于 2021-01-29 09:45:36
问题 I believe I have the Microsoft Authentication Library (MSAL) JavaScript pulling back a JWT token, using azure AD multi tenant with the following config. Based of this link https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-convert-app-to-be-multi-tenant. I believe I only need the following two values. clientId: "A134d6c8-8078-2924-9e90-98cef862eb9a" // this would be the app registrations client id(application) authority: "https://login.microsoftonline.com/common" How then

The model item passed into the is of type 'LoginModel', but this instance requires a model item of type 'HomeViewModel'

本秂侑毒 提交于 2021-01-29 09:26:14
问题 The full text of the error I am getting An unhandled exception occurred while processing the request. InvalidOperationException: The model item passed into the ViewDataDictionary is of type 'FashionNova.Web.Areas.Identity.Pages.Account.LoginModel', but this ViewDataDictionary instance requires a model item of type 'FashionNova.Web.ViewModels.HomeViewModel'. This is my HomeController namespace FashionNova.Web.Controllers { using FashionNova.Services; using FashionNova.Web.ViewModels; using

Axios not authenticating to API

戏子无情 提交于 2021-01-29 08:20:19
问题 Ive been trying all day to get data from my Asp.Net Api but with no avail. I login and get an authentication token from the server and store it locally but when I try to perform any action that requires authentication, the server returns a 401 response. Is there something Im doing wrong in my code? When I use a tool like postman, everything works okay but not in my app. This is my login try { response = await API.post(AuthUrl, credentials) if(response.status >= 200 || response.status <= 299){

How to build a query with Microsoft.AspNetCore.Http.Extensions.QueryBuilder

纵饮孤独 提交于 2021-01-29 04:28:25
问题 I have been looking a ways to build a query in .NET Core Web API and I have discovered the Querybuilder in Microsoft.AspNetCore.Http.Extensions Its not clear to me how to use it. [Fact] public void ThisTestFailsWithQueryBuilder() { string baseUri = "http://localhost:13493/api/employees"; string expected = "http://localhost:13493/api/employees/1?Role=Salesman"; var kvps = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("id", "1"), new KeyValuePair<string, string>(

Passing List object and int to web api

回眸只為那壹抹淺笑 提交于 2021-01-28 23:09:55
问题 I have a web api core project that if I send just the list parameter than the API receives the values, however if I send both parameters that the controller is looking for then both parameters are seen as null My contoller: [HttpPost] [Route("/jobApi/RunBD")] public int RunBDReport([FromBody]int month, [FromBody] IEnumerable<ClientModel> clients) { billingDetailCycle objBillDetail = new billingDetailCycle(); if (ModelState.IsValid) { return objBillDetail.Run(clients.ToList(), month); } else {

Passing List object and int to web api

大兔子大兔子 提交于 2021-01-28 22:47:46
问题 I have a web api core project that if I send just the list parameter than the API receives the values, however if I send both parameters that the controller is looking for then both parameters are seen as null My contoller: [HttpPost] [Route("/jobApi/RunBD")] public int RunBDReport([FromBody]int month, [FromBody] IEnumerable<ClientModel> clients) { billingDetailCycle objBillDetail = new billingDetailCycle(); if (ModelState.IsValid) { return objBillDetail.Run(clients.ToList(), month); } else {

Can't figure out how to inject LinkGenerator

假装没事ソ 提交于 2021-01-28 11:02:14
问题 So I know how to setup my controller so that I can accept a LinkGenerator injected into the controller. What I can't figure out is how do I inject my controller at startup with a LinkGenerator. Controller protected readonly LinkGenerator _linkGenerator; public SomeController(config config, LinkGenerator linkGenerator) { config = Config; _linkGenerator = linkGenerator; } StartUp - ConfigureServices Controllers.SomeController someController = new Controllers.SomeController(config, linkGenerator

Unable to fix veracode cwe id 918 flaw (SSRF) when using API gateway pattern in a Microservices architecture

ε祈祈猫儿з 提交于 2021-01-28 09:02:39
问题 I am using API Gateway Pattern in a Micro services architecture in which the Front End Angular app makes an HTTP request to my API Gateway project which is simply a ASP.net Core 3.1 Web API project. Currently I only have 2 micro services and an API Gateway and all of them are of type ASP.net Core 3.1 Web API project. The API Gateway project has all the controllers of my micro services . The purpose of the API Gateway is just to receive the request from Front end and make an HTTP Request to

How to avoid the circular referencing asp.net core mvc [HttpPost(“add-recipe”)] web api

怎甘沉沦 提交于 2021-01-28 08:26:57
问题 My project is Application with Recipes (cooking) .NET Core 5.0 And i have problem with adding a new recipe (HttpPost) web api On postman my response is: "A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 32. Consider using ReferenceHandler.Preserve on JsonSerializerOptions to support cycles." When i'm creating a new recipe it should use recipeToCreateDto instead of Recipe - which contains all properties