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<T>(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>(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(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>(TEntity)Validates the given entity and adds the validation errors to the ModelState under an empty prefix.
Validate<TEntity>(TEntity, String)Validates the given entity and adds the validation errors to the ModelState.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值