码迷,mamicode.com
首页 > 其他好文 > 详细

404页面

时间:2014-11-08 18:11:31      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   io   color   ar   sp   div   on   

web config 设置

  <system.web>
    <customErrors mode="On" defaultRedirect="error.asp" redirectMode="ResponseRewrite">
      <error statusCode="404" redirect="404.aspx" />
    </customErrors>  
  </system.web>
  <system.webServer>
    <httpErrors errorMode="Custom">
      <!--有3中 Custom, DetailedLocalOnly, Detailed-->
      <remove statusCode="404" />
      <error statusCode="404" path="/404.aspx" responseMode="ExecuteURL"  />
    </httpErrors>
  </system.webServer>

在404.aspx.cs

    protected void Page_Load(object sender, EventArgs e)
    {
        Response.StatusCode = 404;
    }

 

如果是自己处理route Uri 的话 

    try
    {
        throw new HttpException(404, "PageNotFound"); //可以 throw to 404page
    }
    catch (Exception ex) 
    {
        throw ex;
    }

 

404页面

标签:style   blog   http   io   color   ar   sp   div   on   

原文地址:http://www.cnblogs.com/keatkeat/p/4083732.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!