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
0
votes
1 answer
Reach .net web api from another pc
I'm working on a project, where I need to provide a REST API for clients, which will return some data form a database in JSON format.
'Till now here is my code for the controller:
[Models.AllowCors]
public HttpResponseMessage Get(string Id)
…

Norbert
- 25
- 8
0
votes
1 answer
Api controller throw an async related exception
I'm building a Tic-Tac_toe api game. The game work ok, until one of the players press on a square that finish the game(either he wins or fill the board).
When I enabled all CLR exceptions for the last move, this is the exception I saw for line var…

john Cohen
- 13
- 5
0
votes
5 answers
How to use Query String parameters in the ASP.NET MVC API
[RoutePrefix("web/api")]
public class UsersController : BaseController
{
[Route("users")]
[HttpGet]
public Response
- > Get(string q, string ex)
I am trying to make the get function respond to :
web/api/users?q=sd&ex=1
But…

Rahul Kushwaha
- 421
- 7
- 14
0
votes
1 answer
odata query works again ApiController but does not work again ODataController
I try use System.Web.OData.ODataController in WebAPI 2.
WebConfig.cs
ODataModelBuilder builder = new ODataConventionModelBuilder();
builder.EntitySet("User");
config.MapODataServiceRoute(
routeName:…

the.void
- 13
- 5
0
votes
1 answer
Make a page with an overview of all available api's in asp.net mvc
I'm making web API's whit ASP.NET MVC. I've get an example form a theater and I see that he has made an overview of all available API's. How Can I made that into my own website?
Here is the overview:
This is the detail page where you can see the…

H. Pauwelyn
- 13,575
- 26
- 81
- 144
0
votes
2 answers
asp.net redirect to ApiController POST method
I have an ASP.NET application with Forms Authentication, and is now implementing ApiControllers.
On my login page, I forward the user to the call he wanted after I signed him.
FormsAuthentication.RedirectFromLoginPage
And it works fine, IF it is a…

Peter Steiness
- 1
- 2
0
votes
1 answer
To pass HttpRequestBase as a parameter
I have a method GetIP() which takes the System.Web.HttpRequestBase as a parameter.
Could anyone help on how do I get the HttpRequestBase object.
I assume it's really basic but not able to figure out.
Thank you.

Renu R
- 69
- 2
- 12
0
votes
0 answers
Sending a HashSet to a C# ApiController
I have a C# object MyObject with a HashSet property. I serialise it client-side, and then send it via GET with parameters in the URI to a C# ApiController, which accepts the object as an argument:
public MyOtherObject Get([FromUri] MyObject obj) {…

Alec
- 2,432
- 2
- 18
- 28
0
votes
3 answers
When posting to an ApiController the 2nd parameter is null
I am writing an API which will receive via post a UTF-16 encoded string of data which is in reality XML. The problem I am running into is the data parameter in the controller method signature is null. The first paramater, which is the API key is…

Hoodlum
- 1,443
- 1
- 13
- 24
0
votes
0 answers
How to send current Session from MVC Controller to APIController?
I have created a session in MVC Controller, but now i have to use that session in other ApiController.
The problem is the context of MVC Controller is different from ApiController, so is there any way to send current Session information from MVC…

dieuvd
- 29
- 2
0
votes
1 answer
Custom API controller returns no records
I need to return the results from a sql query to my mobile app.
I have a database on azure and a mobile service.
I have added a new custom API controller to my service, but I can't get any records back. I've been reading and reading and still do…
0
votes
1 answer
Difference between HttpControllerContext.Request and HttpContext.Current.Request
Im just trying to Unit-Test my custom ApiController. In my custom controller i override the Initialize method to evaluate the authorization-header.
So my problem is, that i there are 2 request-headers available.
protected override void…

Daniel
- 486
- 4
- 19
0
votes
1 answer
POST Complex Object to ApiController Subclass
I am working on an API method that should accept an Image model object, which has a property List Comments. The Image POSTed from the mobile app works fine but if I include an array of Comment objects they aren't showing up on the instance…

CWitty
- 4,488
- 3
- 23
- 40
0
votes
2 answers
How to change Views in MVC from API controller?
I have a mvc application and I want to know how to change views (cshtml pages) from API Controller not mvc controller. It is because of the cshtml and application communicate through ajax services.
Please reply me as soon as possible. Thanks

gayan1991
- 753
- 2
- 11
- 35
0
votes
0 answers
Using POST for .NET ApiController action with name starting with "Delete"
I'd like to have an ApiController with a controller action that accepts POST requests and has a name that starts with Delete. I'm using the following jQuery:
function DeleteMyDomainObjectButton_OnClick() {
var $div =…

Becca Dee
- 1,530
- 1
- 24
- 51