Category "asp.net-web-api"

How to test database methods and get code coverage xUnit ASP.NET

I initially used the Moq library for testing, since I don't actually want to mess the data in my database. However, I quickly realized instead of running the co

Request.Content.IsMimeMultipartContent() fails

I'm trying to upload a file using the Html2 input type="file" and an angular2 http.post request. When the request reaches the web api, it fails in the Request

How can I catch an exception and send it as json message?

I wrote a code but for some reason it doesn't work...can you tell me what's wrong? I want the app not to stop when I get an exception, only to send that excepti

Enabling authentication in swagger

I created a asp.net core empty project running on .net6. I am coming across an issue when I am trying to enable authentication in swagger. Swagger UI runs as ex

System.Net.WebException: Error: NameResolutionFailure when Calling WEBAPI in xamarin forms

I have created one simple xamarin form application using PCL, which is showing data in listview using WEBAPI. When i call WebAPI , i am getting below error. ex

Testing web API service

I'd like to test the methods of a given Web API service. I could do this by adding a test project, instantiating the controllers and testing the methods. Howeve

How to return a file using Web API?

I am using ASP.NET Web API. I want to download a PDF with C# from the API (that the API generates). Can I just have the API return a byte[]? and for the C# ap

ASP.NET Core: Error while Updating Migration (Database first approach)

I have created an application in .NET Core where I am trying with database first approach. I was able to add Migration using "Add-Migration InitialCreate" but

Make sure that the controller has a parameterless public constructor error

I have followed this tutorial which has worked great, until I modified my DbContext to have an additional constructor. I am now having issues with the resolutio

Issue: No 'Access-Control-Allow-Origin' header is present on the requested resource

My problem is that I can't access to GET method from my Angular app because of the issue: Access to XMLHttpRequest at 'https://localhost:44337...' from origin '

How to read request body in an asp.net core webapi controller?

I'm trying to read the request body in the OnActionExecuting method, but I always get null for the body. var request = context.HttpContext.Request; var stream =

Make Https call using HttpClient

I have been using HttpClient for making WebApi calls using C#. Seems neat & fast way compared to WebClient. However I am stuck up while making Https calls.

Make Https call using HttpClient

I have been using HttpClient for making WebApi calls using C#. Seems neat & fast way compared to WebClient. However I am stuck up while making Https calls.

'Could not find file ... bin\roslyn\csc.exe' [duplicate]

In Visual Studio 2017, when hitting Ctrl+F5 to run my ASP.NET Framework Web API server, I get: Could not find file ... bin\roslyn\csc.exe:

Why ASP Net Core 2.2 do not release memory?

I'm testing ASP Net Core 2.2 using default project made from: Visual Studio > File > New > Project > ASP NET Core Web Application > Next > Cr

WEB API Controller not loading in browser

Having some issues getting started in C#, here's the error I'm getting: HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its

WEB API Controller not loading in browser

Having some issues getting started in C#, here's the error I'm getting: HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its