System.Web.Http下ApiController类

属性

名称 描述
ActionContext 获取ActionContext
Context 获取http上下文
ControllerContext 获取或设置ControllerContext
MetadataProvider 获取IModelMetadataProvider
ModelState 在模型绑定过程之后获取模型状态。 在模型绑定发生之前,此ModelState将为空。
ObjectValidator 获取或设置IObjectModelValidator
Request 获取或设置HTTP请求消息.
Url 获取用于生成其他API的URL的工厂
User 获取或设置与此请求关联的当前主体

方法

名称 描述
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(HttpStatusCode, T) Creates a NegotiatedContentResult 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()
Dispose(Boolean)
InternalServerError() Creates an InternalServerErrorResult (500 Internal Server Error).
InternalServerError(Exception) Creates an ExceptionResult (500 Internal Server Error) with the specified exception.
Json(T, JsonSerializerSettings, Encoding) Creates an JsonResult (200 OK) with the specified values.
Json(T, JsonSerializerSettings) Creates an JsonResult (200 OK) with the specified values.
Json(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) Creates an OkObjectResult (200 OK) with the specified values.
Redirect(Uri) Creates a RedirectResult (302 Found) with the specified value.
Redirect(String) 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) Validates the given entity and adds the validation errors to the ModelState under an empty prefix.
Validate(TEntity, String) Validates the given entity and adds the validation errors to the ModelState.

你可能感兴趣的:(ASP.NET,Web,API)