Category "asp.net-core-webapi"

ASP.NET Core 5 returning JSON adding $id and $values properties

I'm using ASP.NET Core 5. As below, I'm using System.Text.Json: public IActionResult Index() { var result = GetAllMenuItems(); return Ok(result); } The

Publishing build artifacts failed with an error: Not found PathtoPublish: D:\a\1\s\$(buildStagingDirectory)

Building CI pipeline for .Net core APIs in VSTS. But while building getting the below error. Publishing build artifacts failed with an error: Not found PathtoP

.net core injecting and resolving services

I am trying my hand at .net core web api. I have created a static method for registering my controllers like this: public static class RegistrationExtensions {

How do I resolve the issue the request matched multiple endpoints in .Net Core Web Api

I notice that there are a bunch of similar questions out there about this topic. I'm getting this error when calling any of the methods below. Microsoft.A

Cannot add [FromHeader] attribute for a model/class in ASP.NET Core 6.0 minimal api

I'm trying to add multiple custom headers in the .NET core minimal API, so I added [FromHeader] attribute in front of input parameters. It's working fine, I can

How to directly set response body to a file stream in ASP.NET Core middleware?

Sample code below to write a file stream to Response.Body in an ASP.NET Core middleware doesn't work (emits empty response): public Task Invoke(HttpContext con

How to cancel .Net Core Web API request using Angular?

I have the following two applications Angular 6/7 App .Net Core Web API I am making GET request to API using Angular's HttpClient as shown below this.subscrip

How to return a specific status code and no contents from Controller?

I want the example controller below to return a status code 418 with no contents. Setting the status code is easy enough but then it seems like there is somethi

Issue with API Versioning .NET Core 2.2 UnsupportedApiVersion

I am creating an API and need to have versioning done in it. I am using package Microsoft.AspNetCore.Mvc.Versioning 3.1.3 My StartUp.cs is as follows In Confi

Visual Studio 2019 Not Showing .NET 6 Framework

I've been struggling to change an asp.net core web api project's target framework to .NET 6 which was started using target framework .net5. I've already tried a