MVC返回400 /404/...

return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
//HttpStatusCode statusCode  枚举 
// HttpStatusCode.BadRequest = 400,

public HttpStatusCodeResult(HttpStatusCode statusCode);//带参的构造函数 
HttpStatusCodeResult 构造函数名  



    public HttpStatusCodeResult(HttpStatusCode statusCode)
      : this(statusCode, (string) null)
{
    //调用两个参数的构造函数
}

//传递400,(string)null;
public HttpStatusCodeResult(int statusCode, string statusDescription)
    {
      this.StatusCode = statusCode;  //400
      this.StatusDescription = statusDescription; //null 空对象
}

    /// <summary>获取 HTTP 状态代码。</summary>
    /// <returns>HTTP 状态代码。</returns>
    public int StatusCode { get; private set; }


    /// <summary>获取 HTTP 状态说明。</summary>
    /// <returns>HTTP 状态说明。</returns>
    public string StatusDescription { get; private set; }
//返回400界面或者404界面或其他界面

 

posted @ 2018-01-09 17:17  enych  阅读(184)  评论(0编辑  收藏  举报