Monday, October 11, 2004

Blogging on Demand #2

Every now and again I go through my referral logs to see if there's anything interesting bringing people to my site, and if so, I've started writing a little bit about them.

I've previously written about the arraylist.Copy method after someone landed on my site looking for it in Yahoo.

This week someone landed here looking for "sessionid tutorial example vb.net" from Yahoo.


Session.SessionID returns a String, which is the web server's internal identifier of the current session for that particular user. It is this number that gets passed around in cookies and whatnot that allows ASP.NET applications to manage session state.

Although 99% of the time, normal people will never get to see their sessionID getting passed about (it's all done in the background) there are a couple of situations where the session ID is passed in the request's URL. The most common ones are:

Mobile web forms
Although mobile web apps are getting more widely used out in the real world (I've even written one or two myself), some things, like cookie handling, haven't been adopted in any kind of standard way. Some browsers on some devices have cookie handlig, but not all. As a result, the only way to tie the requests from the browser to the session state being managed on the web server is through the URL. If you ever navigate to a mobile webapp from Internet explorer, you'll notice that the URL in the address bar changes to something like "http://localhost/MyMobileApp/(biiig long number here)/Form1.aspx". The big long number being passed abut is the session ID.

Cookieless Sessions
In the same way that mobile web apps pass the session ID in the request URL, normal web browsers do that as well if you configure your app to use cookieless sessions. Kinda makes sense, really. If your user can't receive cookies, then you need some mechanism to associate the user with the session object.

There are one or two security issues, as well as aesthetic issues when it comes to passing session ID's in the URL. As far as security goes, putting the session ID in the URL makes it easier to copy/paste that URL into their browser and hijack someone's session. Not good, particularly if you have a website with restricted/controlled access areas.

Aesthetically, as well, it looks ugly. Big long URLs are bad enough, but put a session ID in there, in brackets, and that's just getting silly. If you've built your app properly, then if someone comes back with an invalid session ID, then nothing'll happen. Your app will gracefully handle the situation, and your user can continue as normal. I only mention this because of one of the other problems with cookieless sessions - if your app doesn't handle an invalid session ID properly, then you're going to have a number of users upset with you because they can't bookmark your site.

Well, that's about all you can say about SessionID. It's a member of the System.Web.SessionState.HttpSessionState class, and is used by the server to differentiate bewteen user sessions.

That is all.

Sexy Sexy

My mouse packed up a littl ewhile ago, and my emergency mouse gave up the ghost last week. As a result I've spent the past week not being able to click/drag anything. It's been an experience, I can tell you!

Anyway, I've just been down to PC world and picked myself up one of these little beauties!.

It's terribly sexy and a very beautiful thing.

Just needed to share.

Saturday, October 09, 2004

Census madness

Nobody really likes giving all their personal information out. Lengthy registration processes, identity rape and the like really wind people up. Especially me.

We know it's not a particularly new idea, ever since the Doomsday book, the powers that be have kept records about everyone in the land. And now there's the census to content with. Which is fine, if you're into that kind of thing. Not everybody is, though. At the last census a couple of years ago, there was a bit of a mission to get Jedi acknowledged as a religion. Turns out Brighton has the most in the UK (2%).

What I found out today was that it's not a new idea at all. They did it in 1901 as well. Either that, or someone's been cursed from birth being called William Poop.

Well I thought it was interesting, anyway.

Wah!

Just when you think your blog's going down the pan, with nothing on it at all worth reading, the great lord himself links to your blog. (And before you start asking, yes. I am trying to curry favour so I'm more likely to win free stuff.

Just thought I'd mention it.

And hey. Leave comments. I don't care how irrelevant they are, or what. Leave commentary. Even if it's just to call me a jerk, I wanna know. Do it. YES, do it! Now!

PS - if this post looks a bit crazy, it's for one/many/all of these reasons:

  1. It's nearly 5 am and I've been up all night listening to DotNetRocks...
  2. Whilst drinking scotch...
  3. After quite a good evening (sorry, nothing to do with code, computers, or anything like that. I'm just in a good mood.)
Just wanted to share.

Friday, October 08, 2004

Well, at least I'm not going to Hell yet...

Looks like, at the time of writing, my blog is only a mere third Evil.

This site is certified 33% EVIL by the Gematriculator

It's more evil than Rory's blog (28%), but less evil than MSDN (58%). So that's OK.

That is all...

EDIT: After I added this entry to my blog, my evil rating dropped to just 23%. I'm keeping the 33% rating, though.

Edit to the Edit: Although my blog Evil rating has gone down, it turns out, in a rather cool way, that my name is 99% evil. I'm impressed.

Thursday, October 07, 2004

What I learnt this week...

I spend quite a lot of my time learning how to do stuff. This is why many of the little ptojects I start working on amount to nothing. In that way, I guess I'm kinda like a mathematician, the guys who go "Well, we'll solve the problem to this point, but then, of course we already know how to do it from here, so there's no point doing it again."

Sometimes it's kinda cool that way. I do at least keep myself interested and avoid doing a whole load of drudgery (and by drudgery, I mean 'stuff I already know how to do')..

Anyway. I learn how to do stuff. And this is what I've learnt how to do this week:
Using SQL Server SCHEMA_INFORMATION

The SCHEMA_INFORMATION views give you a way of writing stored procedures that can pull out some of the metadata about your database. You can pull out data about tables, columns, contraints and all sorts of other stuff about how your database is structured.

I thought it was kind of useful. Particularly for the code generation widget I'm writing at the moment.

Quick note to self:
Regarding the code that's actually generated, I'm making it generate abstract classes, rather than getting it to generate normal classes for 2 reasons:

  1. I can extend them nicely once they're done
  2. I can make a DB design change and regenerate the code. It'll sling out a whole load of compiler errors, depending on what's actually been changed, but (and here's the inportant part) it won't overwrite what I've already done to it
  3. It'll force me to think more about inheritance when I'm actually using the code generated from it. So far I've coding without really using inheritance that much. Bad me! I need to make myself get my head well and truly round it


That is all. Just wanted to share.

That's what I was after...

Just found UI Patterns and Techniques (via Duncan Mackenzie)

I've been looking for a site like this for a while now. UI design is something that I've been kind of thinking abot for a little while. There's a very good site here that's got just bucketloads of UI design disasters and successes. Unfortunately, it's starting to get a bit old (It hasn't been updated or a number of years...), and although a lot of the advice on there is still very valid, there are some aspects where the technology and users have moved on and adopted (rightly or wrongly) some of the design widgets on there.

Patterns and Techniques is more up to date, featuring a lot of the design-schema (if that's a real world) adopted from the web. Although I'm not a big fan of web-style windows apps, I know many people do find them quite familiar and intuitive to use, so I guess they're here to stay.

Just wanted to share.

Aren't I nice?

I'm entering Rory's stupid contest, and I'm lowering my chances of winning by telling you about it, too - neopoleon.com
I mean nice about lowering my chances of winning. I know I'm not nice in real life...

Wednesday, October 06, 2004

Youch!!

The muse came and bit me really hard the other day.

I think I must have been thinking of 6 things at once, when all of a sudden all these things got jumbled together and started joining up. I was thinking of something like this:

  1. Bill Vaughn's presentation at DevDays about data access in Smart Client applications
  2. Rory Blyth's general bias against Datasets (I'd link to something specific, but I can't remember exactly where I heard it
  3. This Episode of DotNetRocks with Scott Hanselman talking about code generation
  4. A conversation I was having with a friend of mine about how it's quite dull and boring essentially building a data model in SQL Server, and then translating that into a set of .NET classes to use in an app
You can probably see where this is going...

I've decided to see if I can write a little app that automatically generates classes from a SQL Server database. As I see it, it'll go through the DB, convert all the tables to classes. Sounds simple. And it will be. It won't be a giant multi-functioned fully fuctional code-generation app with accompanying syntax and stuff. It'll just be something I use to create classes after I've built a DB. I always prefer building a DB to model my data to doing it just in code. It's probably just me and the way I think. I've been working with databases longer than I've been writing .NET, so I just find it easier to conceptualise it this way.

The key things my little script will do are:
  • Generate interfaces for each object
  • Create abstract classes that implement each interface
  • Generate either dynamic SQL or a stored procedure on the server to handle data access
So that's that.

As I go along, I'll expand a bit more. But it's quite fun at the moment.

Sunday, October 03, 2004

What's wrong with this picture?

I've just been looking up some event info on MSDN, and I came across this page.

Now here's a little exercise:

  1. Read the first 5 menu options, or the first 5 links along the bottom. Just the first five, mind you!
  2. Based on those first five values, take your best guess at how they're ordered.
  3. Find United Kingdom.
Now normally I see this list organised alphabetically. I know that the UK's 2 rows below the USA (I think, it might be 3), after United Arab Emirates.

What crazy ordering scheme lead the web developer here to put United Kingdom between France and Greece?

Well, you don't really have to answer that. I think I've got it figured. The name of the region (France, United Kingdom etc.) is taken from the culture defined by the system. That's fine. That's why there are so many. I can handle that.

Where it falls down, however, is whoever put the page together ordered the list items by the specific culture key (e.g. the 'us' in 'EN-us'). The specific culture key for the UK is 'gb' (That's why the URL in the link above ends in 'culture=en-us') which is why the UK sits between France ('fr') and Greece ('gr', I think).

Would it have been that much hassle to order the list by the output text, rather than the culture name? Oh well. It does give me another thing to remember next time I'm building something with data:

Make sure your lists 'n' stuff are ordered using some sort of sensible, obvious scheme.

Just wanted to share.