gpt4 book ai didi

c# - 如何使用 asp.net mvc View 返回 404

转载 作者:IT王子 更新时间:2023-10-29 04:45:52 26 4
gpt4 key购买 nike

如何实现以下功能?

我的 Controller :

if (something == null)
{
//return the view with 404 http header
return View();
}

//return the view with 200 http header
return View();

最佳答案

随便写

Response.StatusCode = 404;

在返回 View 之前。

关于c# - 如何使用 asp.net mvc View 返回 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13764685/

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