About 52 results
Open links in new tab
  1. Difference between ApiController and Controller in ASP.NET MVC

    Feb 29, 2012 · Note If you have worked with ASP.NET MVC, then you are already familiar with controllers. They work similarly in Web API, but controllers in Web API derive from the ApiController class instead of Controller class. The first major difference you will notice is that actions on Web API controllers do not return views, they return data.

  2. How to add Web API controller to an existing ASP.NET Core MVC?

    Jul 5, 2017 · Running existing .net core MVC: In order to add api controllers to existing .net core 6 mvc application, Open Program.cs file, add following codes:

  3. Using async/await or task in web api controller (.net core)

    Jan 31, 2017 · I have a .net core API which has a controller that builds an aggregated object to return. the object it creates is made of data that comes from 3 method calls to a service class. These are all independent of each other and can be run in isolation from each other.

  4. How to specify ContentType for Web API controller method

    Apr 30, 2014 · You do not want to return HttpResponseMessage as that returns the response your own Controller Method got from calling a second server's API for data. It just packages up that response into JSON and sends that to your caller. Bad idea! ASP.NET Core in 2023 has updated the Response Types for Web API and MVC.

  5. asp.net - Web API Routing - api/ {controller}/ {action}/ {id ...

    Attribute routing definitly solves the problem. One important point: Prior to Web API 2, the Web API project templates generated code like this: protected void Application_Start() { WebApiConfig.Register(GlobalConfiguration.Configuration); }If attribute routing is enabled, this code will throw an exception.

  6. Returning http status code from Web Api controller

    May 18, 2012 · For ASP.NET Web Api 2, this post from MS suggests to change the method's return type to IHttpActionResult. You can then return a built in IHttpActionResult implementation like Ok , BadRequest , etc ( see here ) or return your own implementation.

  7. Single controller with multiple GET methods in ASP.NET Web API

    Feb 29, 2012 · The concept of multiple methods in a single asp.net web api controller makes it easier to have more than 1 method in code. I was able to implement following the steps in the above solutions and came up with this final code. In the WebApiConfig.cs ,set up the following Route config, in this order

  8. How to set up a Web API controller for multipart/form-data

    The above code will stay in your Web API Controller that accepts multipart/form-data. Once the code verifies its a multipart content we get the file and extra data like "companyname", ... and you can process your file, save it and return the desired result. You can use angular/.net code to access this method –

  9. Get the current user, within an ApiController action, without …

    Feb 7, 2014 · @ShaunLuttin Ok, so if you are using Web API 1 then you I believe there is a Prinicpal property on ApiController. This is just a fancy wrapper around accessing the Request.Properties collection. The principal object is stored in that dictionary.

  10. How is the Web API Controller's constructor called?

    According to this article, a Controller should have a constructor that gets the interface to be implemented passed in, a la: public class DuckbillsController : ApiController { IDuckbillReposit...

Refresh