ApiController Class

Definition

Defines properties and methods for API controller.

[Microsoft.AspNetCore.Mvc.Controller]
[Microsoft.AspNetCore.Mvc.WebApiCompatShim.UseWebApiActionConventions]
[Microsoft.AspNetCore.Mvc.WebApiCompatShim.UseWebApiOverloading]
[Microsoft.AspNetCore.Mvc.WebApiCompatShim.UseWebApiParameterConventions]
[Microsoft.AspNetCore.Mvc.WebApiCompatShim.UseWebApiRoutes]
public abstract class ApiController : IDisposable
public abstract class ApiController : IDisposable, System.Web.Http.Controllers.IHttpController
[<Microsoft.AspNetCore.Mvc.Controller>]
[<Microsoft.AspNetCore.Mvc.WebApiCompatShim.UseWebApiActionConventions>]
[<Microsoft.AspNetCore.Mvc.WebApiCompatShim.UseWebApiOverloading>]
[<Microsoft.AspNetCore.Mvc.WebApiCompatShim.UseWebApiParameterConventions>]
[<Microsoft.AspNetCore.Mvc.WebApiCompatShim.UseWebApiRoutes>]
type ApiController = class
    interface IDisposable
type ApiController = class
    interface IHttpController
    interface IDisposable
Public MustInherit Class ApiController
Implements IDisposable
Public MustInherit Class ApiController
Implements IDisposable, IHttpController
Inheritance
ApiController
Attributes
Implements

Constructors

ApiController()

Properties

ActionContext

Gets the action context.

Configuration

Gets the HttpConfiguration of the current ApiController.

Context

Gets the http context.

ControllerContext

Gets the HttpConfiguration of the current ApiController.

MetadataProvider

Gets the IModelMetadataProvider.

ModelState

Gets the model state after the model binding process.

ObjectValidator

Gets or sets the IObjectModelValidator.

Request

Gets or sets the HttpRequestMessage of the current ApiController.

RequestContext

Gets the request context.

Url

Gets an instance of a UrlHelper, which is used to generate URLs to other APIs.

User

Returns the current principal associated with this request.

Methods

BadRequest()

Creates a BadRequestResult.

BadRequest(ModelStateDictionary)

Creates an InvalidModelStateResult (400 Bad Request) with the specified model state.

BadRequest(ModelStateDictionary)

Creates an InvalidModelStateResult with the specified model state.

BadRequest(String)

Creates an System.Web.Http.Results.ErrorMessageResult (400 Bad Request) with the specified error message.

Conflict()

Creates a ConflictResult (409 Conflict).

Content<T>(HttpStatusCode, T)

Creates a <see cref="T:System.Web.Http.NegotiatedContentResult`1" /> with the specified values.

Content<T>(HttpStatusCode, T, MediaTypeFormatter)

Creates a <see cref="T:System.Web.Http.FormattedContentResult`1" /> with the specified values.

Content<T>(HttpStatusCode, T, MediaTypeFormatter, MediaTypeHeaderValue)

Creates a <see cref="T:System.Web.Http.FormattedContentResult`1" /> with the specified values.

Content<T>(HttpStatusCode, T, MediaTypeFormatter, String)

Creates a <see cref="T:System.Web.Http.FormattedContentResult`1" /> with the specified values.

Created(String, Object)

Creates a CreatedResult (201 Created) with the specified values.

Created(Uri, Object)

Creates a CreatedResult (201 Created) with the specified values.

Created<T>(String, T)

Creates a CreatedNegotiatedContentResult<T> (201 Created) with the specified values.

Created<T>(Uri, T)

Creates a CreatedNegotiatedContentResult<T> (201 Created) with the specified values.

CreatedAtRoute(String, Object, Object)

Creates a CreatedAtRouteResult (201 Created) with the specified values.

CreatedAtRoute<T>(String, IDictionary<String,Object>, T)

Creates a CreatedAtRouteNegotiatedContentResult<T> (201 Created) with the specified values.

CreatedAtRoute<T>(String, Object, T)

Creates a CreatedAtRouteNegotiatedContentResult<T> (201 Created) with the specified values.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Dispose(Boolean)

Releases the unmanaged resources that are used by the object and, optionally, releases the managed resources.

ExecuteAsync(HttpControllerContext, CancellationToken)

Executes asynchronously a single HTTP operation.

Initialize(HttpControllerContext)

Initializes the ApiController instance with the specified controllerContext.

InternalServerError()

Creates an InternalServerErrorResult (500 Internal Server Error).

InternalServerError(Exception)

Creates an ExceptionResult (500 Internal Server Error) with the specified exception.

Json<T>(T)

Creates a JsonResult<T> (200 OK) with the specified value.

Json<T>(T, JsonSerializerSettings)

Creates a JsonResult<T> (200 OK) with the specified values.

Json<T>(T, JsonSerializerSettings, Encoding)

Creates a JsonResult<T> (200 OK) with the specified values.

NotFound()

Creates a NotFoundResult.

Ok()

Creates an OkResult (200 OK).

Ok<T>(T)

Creates an OkNegotiatedContentResult<T> with the specified values.

Redirect(String)

Creates a redirect result (302 Found) with the specified value.

Redirect(Uri)

Creates a redirect result (302 Found) with the specified value.

RedirectToRoute(String, IDictionary<String,Object>)

Creates a redirect to route result (302 Found) with the specified values.

RedirectToRoute(String, Object)

Creates a redirect to route result (302 Found) with the specified values.

ResponseMessage(HttpResponseMessage)

Creates a ResponseMessageResult with the specified response.

StatusCode(HttpStatusCode)

Creates a System.Web.Http.StatusCodeResult with the specified status code.

Unauthorized(AuthenticationHeaderValue[])

Creates an UnauthorizedResult (401 Unauthorized) with the specified values.

Unauthorized(IEnumerable<AuthenticationHeaderValue>)

Creates an UnauthorizedResult (401 Unauthorized) with the specified values.

Validate<TEntity>(TEntity)

Validates the given entity and adds the validation errors to the model state under the empty prefix, if any.

Validate<TEntity>(TEntity, String)

Validates the given entity and adds the validation errors to the model state, if any.

Applies to