zoukankan      html  css  js  c++  java
  • 解决网站发布404返回200,301等状态

    1、在404.aspx中加入代码: 
    Response.Status = "404 Moved Permanently"; 
    如果你没有做伪静态,或者没加脚本映射,以上完全没有问题,不必往下看了。如果做了伪静态,那么404页面返回的状态码仍然为302,请看第二步。 
    2、在 Global.asax 中加入下面的代码: 
    代码如下:
     
    [html] view plain copy
    1.    
    2. protected void Application_Error(object sender, EventArgs e)   
    3. {   
    4. //在出现未处理的错误时运行的代码   
    5. this.FileNotFound_Error();   
    6. }   
    7. /// <summary>   
    8. /// 404错误处理   
    9. /// </summary>   
    10. private void FileNotFound_Error()   
    11. {   
    12. HttpException erroy = Server.GetLastError() as HttpException;   
    13. if (erroy != null && erroy.GetHttpCode() == 404)   
    14. {   
    15. Server.ClearError();   
    16. string path = "~/404.aspx";   
    17. Server.Transfer(path);   
    18. //Context.Handler = PageParser.GetCompiledPageInstance(path, Server.MapPath(path), Context);   
    19. }   
    20. }   
    iis里要配置在第二个
  • 相关阅读:
    Bootstrap 插件收集
    target和currentTarget
    微信小程序
    flex
    vue中使用icon和打包
    rem的使用
    vue中使用sass和compass
    vue父子组件传递参数
    weex
    常用软件&&网址
  • 原文地址:https://www.cnblogs.com/zwyAndDong/p/7371641.html
Copyright © 2011-2022 走看看