Requirement:
Pre-Load the ASP.NET Application object and don’t allow other pages in your project to add/modify/delete. Basically, make Application read-only.
Solution:
private void SetApplicationReadOnlyStatus( bool state ) {
Type type = Application.GetType().BaseType;
PropertyInfo readPropInfo = type.GetProperty("IsReadOnly", BindingFlags.NonPublic | BindingFlags.Instance) ;
if( readPropInfo != null ) {
readPropInfo.SetValue( Application,Convert.ChangeType(state,readPropInfo.PropertyType ) ,null);
}
}
private void Page_Load(object sender, System.EventArgs e) {
Application["MyKey"] = "myValue";
// Set application to readonly so that we will not allow any changes.
SetApplicationReadOnlyStatus( true );
try
{
// Try setting a value
Application["MyKey"] = "New value";
Response.Write("You won't see this");
}
catch(Exception ex) {
// You'll end up here
Response.Write(ex.Message);
}
}
Thanks to Sairama for the code!
Updated Link to this post 10:29:31 AM # comment [] trackback []
Paul Allen's Vulcan Mini-PC. Here is another interesting device from CES this week. "A hitherto unknown group within multibillionaire Paul Allen's Vulcan Inc. techno-empire has designed a compact, lightweight, wireless computer that is expected to debut by Christmas for between $1,200 and $1,500." It runs Windows XP. Now this is a device I would want. I have never seen the interest in the OQO. Too big to be a PDA, to small to be a work machine. The Vulcan though is the ultimate mini-PC.
Specs include:
- 5.8-inch screen at 800X400
- 20GB drive
- Support for external keyboard and mouse
- Batteries last for up to four hours
- USB 2 port with external CD-ROM
- WiFi or one of two cellular technologies integrated at the choice of the OEM.
Updated Link to this post 10:25:54 AM # comment [] trackback []
Copyright 2003 Scott Hanselman
Theme Design by Bryan Bell