ApiController Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
[<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
Public MustInherit Class ApiController
Implements IDisposable
- Inheritance
-
ApiController
- Attributes
- Implements
Constructors
ApiController() |
Properties
ActionContext |
Gets the ActionContext. |
Context |
Gets the http context. |
ControllerContext |
Gets or sets the ControllerContext. |
MetadataProvider |
Gets the IModelMetadataProvider. |
ModelState |
Gets model state after the model binding process. This ModelState will be empty before model binding happens. |
ObjectValidator |
Gets or sets the IObjectModelValidator. |
Request |
Gets or sets the HTTP request message. |
Url |
Gets a factory used to generate URLs to other APIs. |
User |
Gets or sets the current principal associated with this request. |
Methods
BadRequest() |
Creates a BadRequestResult (400 Bad Request). |
BadRequest(ModelStateDictionary) |
Creates an InvalidModelStateResult (400 Bad Request) with the specified model state. |
BadRequest(String) |
Creates a BadRequestErrorMessageResult (400 Bad Request) with the specified error message. |
Conflict() |
Creates a ConflictResult (409 Conflict). |
Content<T>(HttpStatusCode, T) |
Creates a NegotiatedContentResult<T> 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. |
CreatedAtRoute(String, Object, Object) |
Creates a CreatedAtRouteResult (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. |
InternalServerError() |
Creates an InternalServerErrorResult (500 Internal Server Error). |
InternalServerError(Exception) |
Creates an ExceptionResult (500 Internal Server Error) with the specified exception. |
Json<T>(T, JsonSerializerSettings, Encoding) |
Creates an JsonResult (200 OK) with the specified values. |
Json<T>(T, JsonSerializerSettings) |
Creates an JsonResult (200 OK) with the specified values. |
Json<T>(T) |
Creates an JsonResult (200 OK) with the specified value. |
NotFound() |
Creates an NotFoundResult (404 Not Found). |
Ok() |
Creates an OkResult (200 OK). |
Ok<T>(T) |
Creates an OkObjectResult (200 OK) with the specified values. |
Redirect(String) |
Creates a RedirectResult (302 Found) with the specified value. |
Redirect(Uri) |
Creates a RedirectResult (302 Found) with the specified value. |
RedirectToRoute(String, Object) |
Creates a RedirectToRouteResult (302 Found) with the specified values. |
ResponseMessage(HttpResponseMessage) |
Creates a ResponseMessageResult with the specified response. |
StatusCode(HttpStatusCode) |
Creates a StatusCodeResult with the specified status code. |
Validate<TEntity>(TEntity, String) |
Validates the given entity and adds the validation errors to the ModelState. |
Validate<TEntity>(TEntity) |
Validates the given entity and adds the validation errors to the ModelState under an empty prefix. |