Class ApiController
Defines properties and methods for API controller.
public abstract class ApiController : IHttpController, IDisposable
- Inheritance
-
ApiController
- Implements
- Inherited Members
Constructors
ApiController()
Initializes a new instance of the ApiController class.
protected ApiController()
Properties
Configuration
Gets or sets the HttpConfiguration of the current ApiController.
public HttpConfiguration Configuration { get; set; }
Property Value
- HttpConfiguration
The HttpConfiguration of the current ApiController.
ControllerContext
Gets the HttpControllerContext of the current ApiController.
public HttpControllerContext ControllerContext { get; set; }
Property Value
- HttpControllerContext
The HttpControllerContext of the current ApiController.
ModelState
Gets the model state after the model binding process.
public ModelStateDictionary ModelState { get; }
Property Value
- ModelStateDictionary
The model state after the model binding process.
Request
Gets or sets the HttpRequestMessage of the current ApiController.
public HttpRequestMessage Request { get; set; }
Property Value
- HttpRequestMessage
The HttpRequestMessage of the current ApiController.
Url
Returns an instance of a UrlHelper, which is used to generate URLs to other APIs.
public UrlHelper Url { get; set; }
Property Value
User
Returns the current principal associated with this request.
public IPrincipal User { get; }
Property Value
- IPrincipal
The current principal associated with this request.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
Dispose(bool)
Releases the unmanaged resources that are used by the object and, optionally, releases the managed resources.
protected virtual void Dispose(bool disposing)
Parameters
disposing
booltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
ExecuteAsync(HttpControllerContext, CancellationToken)
Executes asynchronously a single HTTP operation.
public virtual Task<HttpResponseMessage> ExecuteAsync(HttpControllerContext controllerContext, CancellationToken cancellationToken)
Parameters
controllerContext
HttpControllerContextThe controller context for a single HTTP operation.
cancellationToken
CancellationTokenThe cancellation token assigned for the HTTP operation.
Returns
- Task<HttpResponseMessage>
The newly started task.
Initialize(HttpControllerContext)
Initializes the ApiController instance with the specified controllerContext
.
protected virtual void Initialize(HttpControllerContext controllerContext)
Parameters
controllerContext
HttpControllerContextThe HttpControllerContext object that is used for the initialization.