zoukankan      html  css  js  c++  java
  • asp.net notes

    1. cache's expire problem
       string sendTimeKey = "abc_sendtime";
              //DateTime dtLast = (DateTime)cache[sendTimeKey];
              if (Cache[sendTimeKey] == null)
              {
                  Cache.Insert(sendTimeKey, 1, null, DateTime.MaxValue, TimeSpan.FromSeconds(3));//, CacheItemPriority.Normal, null);
                  Response.Write("no cache, added");
              }
              else
              {
                  Cache[sendTimeKey] = (int)Cache[sendTimeKey] + 1;// .Insert(sendTimeKey, DateTime.Now, null, DateTime.MaxValue, TimeSpan.FromSeconds(50));
                  //if (total >= 100)
                  {
                      Response.Write("has cache");
                  }
              }
              Response.Write(Cache[sendTimeKey].ToString());
      上面的代码会造成一旦进入else语句之后,cache将不会在3秒内过期,除非应用重启,原因是直接cache[key] = value,并未设置cache的过期时间,因此将永不过期,因此如果要让cache在sliding expiration,则应该在else中也使用cache.insert()指定过期时间.
      当然,如果不使用slidingExpiration,而是使用绝对时间过期,则只需要在第4个参数不用dateTime.MaxValue,设置一个相应的时间即可,而最后一个参数则应该为TimeSpan.Zero.
    2.  *.axd文件在http://ip/或机器名方式下访问不了,而在vs2k8的debug模式下可以看到,最后发现是在IIS中需要将application pool设置为classic .net pool,而不是defaultpool即可.
    3. dropdownlist中的value如果有相同的,则可能在选择后面的ListItem时,selectedIndex仍然是指向前面的;另外就是应该在初始化dropdownlist时判断Page.IsPostBack.
    4.  关于使用response.Redirect或response.WriteFile时的一点解决方案
      使用response.Redirect或response.writeFile下载文件时,如果还要对当前页面中的server control进行处理,
      则在处理完所有页面逻辑代码之后,使用js代码重定向到下载文件,否则与UI相关的代码将不会执行.
      ex:
      btnDown_click()
      {
      lbAll.Visible = true;  // 显示另一个linkbutton
              string strStartUpScript = "<script language='javascript' type='text/javascript'>window.location.href='newdown3.aspx?fn=" + Server.UrlEncode(fileName) + "';</script>";
              ClientScript.RegisterStartupScript(Page.GetType(), "PopupScript", strStartUpScript);
      }


  • 相关阅读:
    软件工程课程总结
    团队-Forward团队一阶段互评
    《Forward团队-爬虫豆瓣top250项目-开发文档》
    《结对-结对编程项目作业名称-结对项目总结》
    《结对-结对编项目作业名称-最终程序》
    《结对-结对编项目作业名称-测试过程》
    《20171125-构建之法:现代软件工程-阅读笔记》
    《软件工程课程总结》
    团队编程项目作业6-程序维护
    团队编程项目作业5-小组评分
  • 原文地址:https://www.cnblogs.com/margiex/p/1045783.html
Copyright © 2011-2022 走看看