gpt4 book ai didi

c# - 如何在 IHttpModule 中以 404 结束请求?

转载 作者:太空宇宙 更新时间:2023-11-03 20:21:38 25 4
gpt4 key购买 nike

我正在编写一个新的 IHttpModule。我想使用 BeginRequest 事件处理程序使某些 404 请求无效。如何终止请求并返回 404?

最佳答案

您可以将状态代码显式设置为 404,例如:

HttpContext.Current.Response.StatusCode = 404; 
HttpContext.Current.Response.End();

响应将停止执行。

关于c# - 如何在 IHttpModule 中以 404 结束请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13122124/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com