首页 > Web开发 > 详细

MVC返回400 /404/...

时间:2018-01-09 18:17:22      阅读:170      评论:0      收藏:0      [点我收藏+]
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界面或其他界面

 

MVC返回400 /404/...

原文:https://www.cnblogs.com/enych/p/8252523.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!