198366809 发表于 2021-10-24 12:45:09

ASP.NET 页面404设置

Web.config<system.webServer>
    <!--404-->
    <httpErrors errorMode="Custom" existingResponse="Replace">
      <remove statusCode="404"/>
      <error statusCode="404" responseMode="ExecuteURL" path="/404.aspx"/>
    </httpErrors>
</system.webServer>

404.aspx
<%@ Page Language="C#"%>

<script runat="server">
    /// <summary>
    /// 页面载入
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
      Response.Status = "404 Not Found";
    }
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>404 Not Found</title>
</head>
<body>
   404 Not Found
</body>
</html>来源:C#社区
网址:www.hicsharp.com



阿龙 发表于 2021-10-24 12:45:10

天书奇谭,建议列为中文专业博士学位答辩翻译必考题目。

liuhiulin 发表于 2021-10-24 13:20:48

真是难得给力的帖子啊。

奇迹685 发表于 2025-11-13 14:00:52

蹲一波同款,有没有姐妹 / 兄弟推荐?

是方法为我 发表于 2025-11-13 14:11:57

水个经验,楼主加油,支持你~

lixiaokui09 发表于 2025-11-13 14:13:12

我先占个楼,等下再慢慢看~

长江2019 发表于 2025-11-13 14:13:15

这波分析到位,逻辑满分!

天下独游 发表于 2025-11-13 14:13:21

说得对!狠狠赞同,没毛病~

lxp62828 发表于 2025-11-13 14:16:41

路过混个脸熟,顺便为优质内容打 call~

yy240084 发表于 2025-11-13 14:19:20

谁懂啊!这内容我能循环看十遍
页: [1] 2
查看完整版本: ASP.NET 页面404设置