Category Archives: Programming

Cold Fusion Request Variable Type for ASP.NET

i know i’m late to the party most times but i want to share this with any ASP.Net web developers that will find this as useful as myself… and i find it very useful. i dev’d some Cold Fusion code back in the day… it was a job what can i say… anyhow i remember the coolest variable type ever that CF had.. it was the ‘request’ variable. not to be confused with the ASP and ASP.Net request object. in ColdFusion a request variable is just a generic variable that can be read and written too throughout the entire HTTP request thread… all without needed to be passed around like local variables and without the excessive memory overhead of session variables.

for the last several years while working in a .Net world i’ve had to settle on either explicit passing of local variables (yuck… pain to build for and maintain) or session variables (ugh… easy but you know you’re utilizing a lot more memory than you really need). but today the simplest thing dawned on me… the Page object is scoped very similarly to an HTTP request… and it has an Items collection… and you can read and write entire objects into the Items collection. best of all at the end of the Page’s lifecycle the Items collection is disposed of and the memory is free… free at last!

so there you go, if you’ve ever needed a Cold Fusion style request variable in ASP.Net use Page.Items.

it’s super easy, but here’s an example of setting and reading:

[VB]
‘ this creates the ‘item/variable’
Page.Items.Add(“Name”,”Value”)

‘ this is where you read it
‘ remember you can read from anywhere during
‘ the request (like from a user control)
Response.Write(Page.Items.Item(“Name”))

[C#]
// this creates the ‘item/variable’
Page.Items.Add(“Name”,”Value”)

// this is where you read it
// remember you can read from anywhere during
// the request (like from a user control)
Response.Write(Page.Items.Item[“Name”])

ASP.NET FIX FOR “The serialized data is invalid” ERROR

asp.net developers… have you fallen victim to the dastardly error “The serialized data is invalid“? have you like me tried to reproduce the error during testing only to come up empty handed? well hopefully my latest ASP.Net discovery will help you rid yourself of this pain-in-the-neck bug.

i was recieving this error on a website too frequently to ignore. it appeared that most of the user-agents that were tripping the error were FireFox browsers, with some Opera browsers thrown in for good measure and it wouldn’t be a website bug without a couple of IE’s mixing it up too. however, user-agent was the wrong thing for me to be looking at… it reall boiled down to internet connection speed. yes indeed, dial up users are the best users of all… if you’re trying to code to the nth degree for page load times… who needs rich media anyhow 🙂

(need a >> dialup emulator)

THE ROOT PROBLEM:
when users perform a post-back and the page is not fully loaded (including all of asp.net’s javascript overhead junk) guess what… “The serialized data is invalid” ouch… this is hard to reproduce when you are connecting to your site on a blazing fast modern broadband connection (i like rich media) or locally on a dev box… because the page is inherently going to load so fast that you won’t have time to click a button, drop down menu or whatever other control on your asp.net web page that might post back.

THE FIX:
pre-loaders. you know… the kind of “please wait while the page loads” screens you see when you search almost any serious airfare site (expedia, travlocity, orbitz). pre-loaders prevent users from doing anything until the entire page loads. however, this may add a percieved slowness to your site. i personally don’t mind them… i mean it’s great that google can search 800000000000 billion pages in 1 second… but they also have more invested in data caching and indexing than that most businesses (minus oil companies) could imagine ever getting to spend.

so there you go… when i started looking for the cause of “The serialized data is invalid” i found a lot of chat sites and forums where people where asking and not getting answers…and i’d love to go spread the word, but perhaps the search engines will be so kind to bring anybody searching for “The serialized data is invalid” to this little post… and hopefully this does indeed resolve your issue as it has mine. cause i sure didn’t find it on microsoft.com or the msdn or asp.net (the website)

by the way, does this look familiar:

STACKTRACE: at System.Web.UI.ObjectStateFormatter.Deserialize(Stream inputStream) at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString) at System.Web.UI.ObjectStateFormatter.System.Web.UI.IStateFormatter.Deserialize(String serializedState) at System.Web.UI.Util.DeserializeWithAssert(IStateFormatter formatter, String serializedState) at System.Web.UI.SessionPageStatePersister.Load()

uggh

AJAX Windows (an AJAX based OS)

for the proggers out there… AJAX based OS??? alrighty then… so i read about this company, Ajax13, who has developed an OS that runs inside your browser, which of course runs on the OS installed on your hardware. strange concept… but worthy of some playing around with. unfortunately when i went to check it out and register for an account AjaxWindows.com is being overloaded (so don’t expect a link from here, i don’t want to contribute to their woes).. i think you know how to get to them anyways and if you don’t then you’ve read way too much in this blogging… go back to youtube.

here’s the article i caught about Ajax Windows >> http://news.com/8301-10784_3-9775272-7.html?part=rss&subj=news&tag=2547-1_3-0-5-gtb

and if you want to keep up on cnet’s articles i HIGHLY RECOMMEND the >> CNET News.com Google toolbar button

Free Image-Photo Editor & Graphics Software Download

in the world of free graphics software there isn’t a huge variety… imagine that.. companies wanting to charge for software 🙂 anyhow there are a couple of powerful tools like the GIMP and don’t forget Micro$oft’s Paint… okay so Paint isn’t powerful… it’s almost worthless these days. anyhow, i’ve been using another M$ program “Paint.Net” that is a lot better than the old school Paint… and i like the interface much better than the GIMP’s.

so if you don’t have much cash to spend on image editing software and you don’t like “cracking” expensive products like PhotoShop and you use Windows… checkout Paint.Net >> http://www.GetPaint.Net

W3 Schools – Google Toolbar Button Download

i really like W3 Schools… from time to time i find myself on their site brushing up on something i forgot or learning something new. it’s a tremendous resource for any web developer. at the same time i’m really digging the Google toolbar buttons… i made one for TicketCity.com and i have the one for DomainTools.com installed as well… there are a couple of others i’m sure i’ll get around to installing soon. in the meantime i made a W3 Schools button for the Goog toolbar for myself… but as usual i figure there are other nerds out there who might be interested in the same thing… if so you can install it by clicking here.

the W3 Schools button lets you search their site from the toolbar and i’ve also added links to the major categories… HTML,XML,SQL,JavaScript and on and on.

MS SQL Union (Selects Distinct Values)

here’s a wake up call for devs who use SQL Unions infrequently. at work we recently tripped up on a bug with a stored proc… well it was actually just that we had forgotten that with UNION, only distinct values are selected! oops.

so remember: The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.

gotta love W3Schools >> http://www.w3schools.com/sql/sql_union.asp

ok so don’t poke fun… we just don’t need or use Union much and this little fact slipped through… don’t let it happen to you… you’ve been warned!

Freeware: Compare MS SQL Objects (Tables, Stored Procs, etc)

this is another nifty tool for web programmers and dba’s. its free and it will compare tables, stored procedures, indexes, triggers, users, etc. between two databases (servers too). it’s especially helpful when you develop something in a local environment then need to replicate your changes to a testing environment and then push them to a production environment.

because the author doesn’t seem to list a homepage i’m archiving this gem on my server… you can download it here >> SQLServerCompare.exe

Emulate a Dial-Up Connection for Web-Site Testing

here is some software that will throttle down your connection speed so that you can witness first hand how a website/webpage loads for dial-up users on the internet. it works great as a dial-up emulator. it will emulate 28.8Kb, 33.3Kb and 56Kb.

it’s called Charles << umm... ok then... enjoy. btw, u can do a lot more with it than what i'm mentioning