DotNetKick.com is an open-source project. Please report any bugs and let us know your great suggestions. Currently running svn revision 620 (rss)

Kick Spy!, Kick Zeitgeist and Kick Widgets

15
kicks
published 1 year, 9 months ago, submitted by wwb_99 1 year, 9 months ago

sitepoint.com — ASP.NET gives a developer a lot of loosely typed key-value collections in which to stash stash variables, depending upon persistence needs. The short list includes ViewState, Session, Application and HttpContext.Items. These collections can come in very handy when one needs to keep an object around outside of a single request or shuttle things between different bits of the http pipeline. But it comes at a price—these collections are loosely typed, just returning Objects. Moreover, there is no compile-time checking to ensure that you are requesting the right key in the right place. Errors can lead to crashes at best, and interesting data corruption at worst. Here is a handy technique to avoid such issues.

Add a comment 1 comment | category: | Views: 2 | Get KickIt image code
tags: , , , | tag it

new Add a live kick counter to your blog >> liveImage

You can even customize the image by choosing your own colors, and then clicking the button below to update the preview and the html code:

  • "Kick It" text
  • "Kick It" background
  • kick count text
  • kick count background
  • border

Simply copy and paste this HTML into your blog post.


Users who kicked this story:

Comments:
Eh, sokay article for session variables. I like to create a static class that contains all my session variable access code. Variables are accessed via static properties of the class that are stored in the session under names stored in consts within the class. The properties call an internal method (one for gets and one for sets) that actually retrieve the variables. Also, I use HttpContext.Current to get the current session, checking it for null first to avoid null reference exceptions. It usually happens when the web server is shut down, which becomes annoying when debugging as the web site is shut down and restarted multiple times.

What's more fun is creating generic cache-backed methods to retrieve settings from web.config in a type safe manner....
posted by yesthatmcgurk yesthatmcgurk 1 year, 9 months ago



information Login or create an account to comment on this story
 

Sponsored Link: www.carlist.ie

Search:

Ads via The Lounge