Default redirect for Error 404

前端 未结 4 1488
栀梦
栀梦 2020-12-01 06:19

I want to introduce a functionality in my ASP.net website that, whenever a request is received for an unknown URL on my domain, the user is redirected to my error_404.

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 07:16

    This is how you configure a custom 404 error page for both ASP.NET and non-ASP.NET requests:

    
    
       
          
    
          
             
          
       
    
       
          
             
             
          
       
    
    
    

    As others already pointed out, you should not use an HTTP redirection to send the user to the home page, this is not only confusing to users but also to machines (e.g. search engines). It is important to use the 404 status code and not a 3xx code.

    You can achieve the desired functionality using meta refresh on HTML:

    <%@ Page Language="C#" %>
    
    
    
       Not Found
       
    
    
       

    Not Found

    Redirecting to Home...

提交回复
热议问题