Author: mahdiprog | Posted on: 1/30/2010 6:47:22 AM | Views : 226

We are writing a portal and like every portal we store html data in Db fro Modules. So I thought that I can cache each module in files. I use OnLoad event to check if there is a cache file for this Module, use that and else create cache file:
if (!IsPostBack) { string Path = AppDomain.CurrentDomain.BaseDirectory + "\\Cache\\Modules\\" + ModuleId + ".dat"; if (File.Exists(Path)) { Controls.Clear(); Literal ltCache = new Literal(); ltCache.Text = File.ReadAllText(Path); Controls.Add(ltCache); } else { base.OnLoad(e); StringBuilder SB = new StringBuilder(); StringWriter SW = new StringWriter(SB); HtmlTextWriter htmlTW = new HtmlTextWriter(SW); this.RenderControl(htmlTW); File.WriteAllText(Path, SB.ToString()); } }






&nbs ...

Go to the complete details ...