C#项目学习 心得笔记本

CacheDependency 缓存

            //创建缓存依赖项
            CacheDependency dep = new CacheDependency(fileName);
            //创建缓存
            HttpContext.Current.Cache.Insert(key, obj, dep);
HttpContext.Current.Server.MapPath(strPath);  //获得绝对路径

DirectoryInfo 文件夹类

            DirectoryInfo dirInfo = new DirectoryInfo(Utils.GetMapPath(dirPath));
            foreach (DirectoryInfo dir in dirInfo.GetDirectories())

volatile 关键字

volatile多用于多线程的环境,当一个变量定义为volatile时,读取这个变量的值时候每次都是从momery里面读取而不是从cache读。这样做是为了保证读取该变量的信息都是最新的,而无论其他线程如何更新这个变量。

RewritePath URL重写

HttpContext。HttpContext类中定义了RewritePath 方法,这个方法有四种重载形式,分别是:

RewritePath(String) 使用给定路径重写 URL。
RewritePath(String, Boolean) 使用给定路径和一个布尔值重写 URL,该布尔值用于指定是否修改服务器资源的虚拟路径。
RewritePath(String, String, String) 使用给定路径、路径信息和一个布尔值重写 URL,该布尔值用于指定是否修改服务器资源的虚拟路径。
RewritePath(String, String, String, Boolean) 使用给定虚拟路径、路径信息、查询字符串信息和一个布尔值重写 URL,该布尔值用于指定是否将客户端文件路径设置为重写路径。

原文地址:https://www.cnblogs.com/william-lin/p/3272032.html