You can read the ref and take a look in the Difference between ApiController and Controller in ASP.NET MVC, since people are commonly confused with them.
Questions tagged [asp.net-apicontroller]
456 questions
3
votes
2 answers
ApiController same route for int or string URI params
I would like for my controllers to extent endpoints based on the data-type of the same variable name. For instance method A takes an int and method B takes a string. I don't want to declare a new route but rather for the routing mechanism to…

Krolique
- 682
- 9
- 14
3
votes
2 answers
Create a View against an API controller?
I need to create a website where some of it's pages should be accessible from external clients via an API, but I still want to make regular MVC Razor views to retrieve, display and manipulate the same data.
What's the best way to achieve…

Shimmy Weitzhandler
- 101,809
- 122
- 424
- 632
3
votes
1 answer
Apicontroller inside mvc project - httppost and json method isn't recognized
I have a normal ASP.NET MVC project (not Web API). Here I created a new folder inside my controllers called "api", as I want to create a simple api.
I then create the following class:
public class OfficeProductController : ApiController
{
…

Lars Holdgaard
- 9,496
- 26
- 102
- 182
2
votes
0 answers
How to modify auto [ApiController] validation response for some endpoints only?
I have to modify auto validation response that [ApiController] generates but only for some endpoints, so I can't change ApiBehaviorOptions. I tried using IActionFilter, but the auto validation is done before action filter and I can't modify it this…

Szyszka947
- 473
- 2
- 5
- 21
2
votes
2 answers
.NET 6 API populate extended ProblemDetails class with the default response values
I want to return all error reponses in my API in the application/problem+json format. By default, returning an empty NotFound() or BadRequest() already results in this format. When they are passed values however (e.g. BadRequest("blah")), they loose…

M-Expunged
- 71
- 1
- 6
2
votes
1 answer
ASP NET Core Define API Controller within class
I'm currently switching from .net framework to .net core 3.1.
Defining Api Controllers inside the namespace is all fine and works.
Now I have the case, that I need to declare the Api Controllers within another class, like this:
namespace…

Mello1337
- 21
- 2
2
votes
1 answer
.Net Core RequestHttpMessage AddCookies to Header in .Net Core Web Api
I need to return HttpResponseMessage in one of my controller methods and add a cookie to it in a few cases.
I've referred through few articles but couldn't get it resolved. For instance:
How add Cookies to http request header in ASP .NET Core…

user6095576
- 35
- 8
2
votes
1 answer
How to process Excel file in memory?
I am trying to create an API that will accept the representation of an Excel file from the client. I wish to return a List
- > as JSON array after processing the first sheet. However, I cannot write the file to disk, and all processing…

Kaustubh Badrike
- 495
- 1
- 4
- 18
2
votes
1 answer
Authentication.Challenge not working with ApiController
With ApiController, Authentication.Challenge not prompting Microsoft login for SSO. it executes SignIn action method, with out any errors. If I change from ApiController to Controller then it's prompting. does any one know how to prompt for…

nara
- 21
- 3
2
votes
1 answer
Repository results and status codes in ASP.NET Core API Controller methods
I have an ASP.NET Core API app and I'm using IActionResult for a return type. For an example, I'll use the following snippet from Microsoft's…

Birdman
- 1,404
- 5
- 22
- 49
2
votes
3 answers
Post Action method overload with same route name in ASP.Net Web API Controller
Is it possible to have two actions with same route name and same method but different parameter?
I have tried this:
[HttpPost]
[Route("gstr4")]
public HttpResponseMessage SubmitGSTR4([FromBody] RequestPayloadWithoutSign requestPayload)
{…

Rithik Banerjee
- 447
- 4
- 16
2
votes
1 answer
what is the alternative for Services.AddMvc() and SuperJsonOutputFormatter used in .Net Core 2.2 while migrating to .Net Core 3.1
I'm migrating a .Net Core 2.2 web API application having API Controllers only with no views. I have a custom API response set in my project using SuperJsonOutputFormatter. Now, I'm using NewtonsoftJsonOutputFormatter for creating custom response for…

Rahul Dev
- 141
- 2
- 17
2
votes
1 answer
How to Add Uri to the Created(Status Code 201) of a Post Request
i just started learning asp.net core api and i'm trying to make a post request from Postman. I want to return a status code of 201 upon post and return the Uri of the newly posted data as the location. Below is my controller code
[HttpPost]
…

upsidedownwf
- 134
- 1
- 3
- 12
2
votes
1 answer
Model binding in ASP.NET Core API are always null
I have a simple ASP.NET Core API which I invoke with javascript's fetch method. But the input variable model of type SearchString property is always null.
It works as expected when I invoke it using Postman, but not from javascript, for some…

SteinTheRuler
- 3,549
- 4
- 35
- 71
2
votes
2 answers
An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set. in Blazor
When hitting the controller exception error came "An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set."****strong text
blazor server side
Controller call not perform in the Razor…

novfal haq
- 107
- 2
- 16