Bac*_*ave 1 c# asp.net-web-api
我刚刚阅读了有关Web API 模型验证的内容,它有这个示例,但是下面提供的示例代码将无法编译,CreateErrorResponse()因为HttpRequestMessage. 有谁知道为什么?
public class ValidateModelAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            if (actionContext.ModelState.IsValid == false)
            {
                actionContext.Response = actionContext.Request.CreateErrorResponse(
                    HttpStatusCode.BadRequest, actionContext.ModelState);
            }
        }
    }
Run Code Online (Sandbox Code Playgroud)
    CreateErrorResponse是一个扩展方法,添加using System.Net.Http;
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           1360 次  |  
        
|   最近记录:  |