The What and Where

Something that may not be obvious is if are creating an asp.net WebForms project and you put a datasource such as SqlDataSource or ObjectDataSource for example on the page, how can you prevent the SqlSelect associated with that datasource from being triggered.

The answer is to set the control’s visible property to false.  That’s it!

(more…)

(About 100 People)

The Presentation was broken down into three parts. 

Part 1

Created a windows razor project that cached in image on a web site using best practices for threading and locking.  The code and project to do this are below:

var downloadByteArray = HttpContext.Current.Cache[cacheName] as byte[]; if (downloadByteArray == null) {     // make sure multiple requestors are not filling up the cache     lock (LockVal)     {         downloadByteArray = HttpContext.Current.Cache[cacheName] as byte[];         if (downloadByteArray == null)         {             Thread.Sleep(sleep * 1000);

             string imageLocation = HttpContext.Current.Server.MapPath("~") + imageUrl;

             downloadByteArray = File.ReadAllBytes(imageLocation);             if (cacheExpiresSeconds > 0)             {                 HttpContext.Current.Cache.Insert(cacheName, downloadByteArray,                                                  null,                                                  DateTime.Now.Add(new TimeSpan(0, 0, 0, cacheExpiresSeconds)),                                                  TimeSpan.Zero, CacheItemPriority.NotRemovable, null);                 CacheInsertCounter = 9999; // any touch of this increments the global counter             }         }     } }

 

 

Part 2

Tips from Steve Souders

 

Part 3

Sprite Library from Microsoft Example: 

 

imageIMAG0174IMAG0177


© 2012 PeterKellner.net. All Rights Reserved
Follow

Get every new post delivered to your Inbox

Join other followers: