我试图从 Global asax Application_Error 中抛出这一行
throw new HttpException((int)HttpStatusCode.Unauthorized, "Forbidden");
但由于某种原因,我在浏览器中得到 200 而不是 401,你知道为什么吗?
更新:
protected void Application_Error(object sender, EventArgs e)
{
throw new HttpException((int)HttpStatusCode.Unauthorized, "Forbidden");
}