先看下正常的结束asp.net 请求流怎么写的

System.Web.HttpContext.Current.Response.Write(“end”); 
 System.Web.HttpContext.Current.Response.End(); 

这样写呢,对调用方看来也是可以的,因为收到的返回数据就是end ,可是我们调代码的时候 就会发现,请求流并没有结束,代码接着往下走了。。。 真正的结束请求流并没有起效果。

那么该如何结束webapi的请求流呢?(需要参考webapi如何使用filter

很简单!

public override void OnActionExecuting(HttpActionContext actionContext)
        {
             actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Unauthorized);
        }

 

相关文章:

  • 2022-01-13
  • 2021-11-05
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
  • 2021-12-16
  • 2021-12-26
  • 2022-02-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-25
  • 2021-05-03
  • 2022-01-06
  • 2021-10-14
相关资源
相似解决方案