September 2004 Entries
Umm...OK, I made the title overly descriptive...anyway, I stole this from here:
The MSDN facelift (not MSDN2) hosed the formatting of code samples in Firefox and Mozilla browsers. To fix it, add this to your userContent.css file (chromEdit is the easiest way to modify this file):
/* Microsoft MSDN code stylesheet */
pre
{
white-space: pre !important;
}
Just listening to the new Jean Michel Jarre DVD / Album, Aero - if you haven't heard, this is a collection of many of his old tracks and a couple of new ones - the twist is that the album comes with both a DVD and CD, the DVD contains 5.1 surround sound versions of all the tracks. These surrounds sound versions are just fantastic, I hope that way more albums come in this form in future, it really does add whole new dimesions to the experience. The flash animation below is cribbed from his site - the DV actually contains 73 minutes of Anne Parillaud's eyes filmed while listening to the music (much like the eyes on the album cover below.., very wierd! Anyway, you can get this album here, I recommend it!
OK, so I thought that the
ValidateRequest stuff was a fluke, a dumb mistake - I mean no company would introduce a breaking change to a production framework...even worse you can't even
specify this in the web.config and have it work in all frameworks, well, one mistake, I can forgive that. But no, it's happened again with the
HttpRequest UnsafeHeaderParsing, put simply this stops many applications from fetching web content by
blocking 'unsafe' headers...fine idea, but it breaks existing code. Here's a crazy idea, why not make the
<httpWebRequest useUnsafeHeaderParsing=”true” /> tag required to turn this off instead
<httpWebRequest useSafeHeaderParsing=”false” /> , so leaving it out causes this 'feature' to be disabled.
I know there's an argument for 'security by default' but not if it breaks applications! It's also not obvious enough that
installing .NET 1.1 SP1 will potentially break applications .
Well, I'm finally going to have to wipe my main workstation and reinstall - is it just me or is there always the creeping doubt that you've forgot to back something up? I was just reading a
post on Pachal's blog about the
Community Server stuff (which is where .TEXT has moved to).
Rob Howard left a comment there reassuring us that there'd always be a free version of the CommunityServer products available (so,
.TEXT,
nGallery and
ASP.NET forums as were...)...which is nice... Ah well, once I get my worksatation back up I can get on with attempting to destroy my blog's code
Haviong an issue with my setup right now (might have to reformat my main machine). In the meantime, please still use the
blogcomments@mostlylucid.co.uk is you want to leafve a comment. Thanks.
Wierd, looked at my blog this morning and the post I put up with Server Side Viewstate stuff is messed un - and inactive! Not sure what's going on there, I'll get it back up as soon as I can...
Reading Paschal's stuff on his Irish Developers group, this seems like a great idea. So, here's mine - I know there's lots of Scottish Developers and of those, a lot are .NET developers; what I don't know though is where their blogs are so what I want to do is put togther a list of all of these blogs; which I'll put in the right hand column and link from all of my future posts -as well as provide a page for seeing aggregated content from all those blogs. Only qualification is that you have to be Scottish (i.e., you have to have been born in Scotland) and be a developer working in .NET. If you're interested please email me at scottishdotnet@mostlylucid.co.uk - oh, also email me if you don't yet have a blog but would like one (if I get enough requests I'd be happy to set up an aggregated ala Weblogs.asp.net blog for these users).
UPDATE: Ok, so to remind myself I'll add the list to this post at first:
Michael Falconer
Mike Scott
Stuart Radcliffe
James O'Neill
Hmm...I've spammed myself. I have this application at a customer's site which has an exception logging feature, so each exception logs to the local event log then sends me an email - great idea huh? What I hadn't thought of though is 'what happens if the event log gets full?' - tonight I found out. Turns out that if it can't write to the event log, it sends an email...there seems to be a bit of a bug though - something in there sees a failure to write to the event log as a loggable exception. Unfortunately, the event log got full...resulting in a loop - currently getting about 10 emails PER SECOND! Fortunately I was online when this started so I got it stopped after about 20 minutes (and deleted 300MB+ of mails from the SMTP queue on the server) - I reckon I still have about 10000 emails to get though. Bugger!
Everyone knows I guess that the new
Hitchhikers Guide is on Radio 4, what I just noticed (and am listening to right now) is that the
WMP and
Real streams are in 5.1 surround! Fantastic sound quality and (slightly excessive) surround effects aplenty!
Been trying to find the original article...but I can't so I'll hunt it down later...this code is basically just a rehashed version of that other guy's original with a few of my own enhancements...so, first thisn to get the ViewState to live on your server:
Use a BasePage class which all your ASP.NET pages inherit from, note I use a Config class referenced from Global to hold stuff like filenames, directories etc...you can just substiute the appropriate values (I'll cover this in more detail in a later post):
So past this code into your BasePage:
private static string FilePathFormat = Global.Config.ViewStateServerPath + "{0}" + Global.Config.ViewStateFileExtension;
private const string ViewStateHiddenFieldName = "__ViewStateGuid";
// creates a new instance of a GUID for the current request
private string pViewStateFilePath = Guid.NewGuid().ToString();
/// <summary>
/// The path for this page's view state information (GUID based).
/// </summary>
public string ViewStateFilePath
{
get
{
return MapPath(String.Format(FilePathFormat, pViewStateFilePath));
}
}
/// <summary>
/// Saves the view state to the Web server file system.
/// </summary>
protected override void SavePageStateToPersistenceMedium(object viewState)
{
if(Global.Config.ServerBasedViewState)
{
// serialize the view state into a base-64 encoded string
LosFormatter los = new LosFormatter();
// save the view state to disk
StreamWriter sw = File.CreateText(ViewStateFilePath);
los.Serialize(sw, viewState);
sw.Close();
// saves the view state GUID to a hidden field
Page.RegisterHiddenField(ViewStateHiddenFieldName, pViewStateFilePath);
}
else
{
base.SavePageStateToPersistenceMedium(viewState);
}
}
/// <summary>
/// Loads the page's view state from the Web server's file system.
/// </summary>
protected override object LoadPageStateFromPersistenceMedium()
{
if(Global.Config.ServerBasedViewState)
{
string vsGuid = Request.Form[ViewStateHiddenFieldName];
string vsString = MapPath(String.Format(FilePathFormat, vsGuid));
if (!File.Exists(vsString))
throw new Exception("The Viewstate file " + vsString + " is missing!!!");
else
{
// instantiates the formatter and opens the file
LosFormatter los = new LosFormatter();
StreamReader sr = File.OpenText(vsString);
string viewStateString = sr.ReadToEnd();
// close file and deserialize the view state
sr.Close();
return los.Deserialize(viewStateString);
}
}
else
{
return base.LoadPageStateFromPersistenceMedium();
}
}
This just overrides the default ViewState behaviour, saving the ViewState instead to a file on your server...all that's inserted in the page is a simple GUID (the original used a filename with path - which isn't really a secure thing to do).
Next, you want to clean up these files occasionally. Original used an HttpModule with a Thread.Sleep() to control the cleanup cycle...I just used a Timer like so:
using System;
using System.IO;
using System.Timers;
using System.Web;
using Microsoft.ApplicationBlocks.ExceptionManagement;
namespace Utility
{
/// <summary>
/// Summary description for ViewStateCleaner.
/// </summary>
public class ViewStateCleaner
{
public bool TimerStarted = false;
private static Timer _cleanupTimer;
private static int _expiryMinutes = Global.Config.ViewStateTimeout;
public void startTimer()
{
if(_cleanupTimer == null)
{
_cleanupTimer = new Timer();
}
_cleanupTimer.Interval =TimeSpan.FromMinutes(_expiryMinutes).TotalMilliseconds;
if(!TimerStarted)
{
_cleanupTimer.Elapsed+=new ElapsedEventHandler(_cleanupTimer_Elapsed);
_cleanupTimer.Start();
}
}
public void CleanupFiles()
{
string viewStatePath = HttpContext.Current.Server.MapPath(Global.Config.ViewStateServerPath);
long nowTicks = DateTime.Now.Ticks;
long expTicks = TimeSpan.FromMinutes(_expiryMinutes).Ticks;
foreach(string fileName in Directory.GetFiles(viewStatePath))
{
long diffTicks = nowTicks - File.GetCreationTime(fileName).Ticks;
if(diffTicks >expTicks )
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; mso-layout-grid-align: no
Sorry, I've decided to remove the posts I put up about Microsoft recruitment. I've also disabled comments for this site, if you want to comment on a post please use the contact form for the time being - I'll be implementing a new comments system (which will require email validation) this weekend. I'm really sorry I've had to do this but recent comments have left me with no option...
UPDATE: Umm...or I will, .TEXT seems a little resistant to this...
UPDATE: Looks like there's a bug in the version of .TEXT I'm running, in the end I had to set a flag directly in the DB to do this. As I say, comments will be off until I get a new system in place, I had a total of 12 comments on my post about MS coders in comparison to Apple coders, of which 2 were positive, the rest were very nasty - looking at my log it looks like these came from the same IP / User Agent string so I guess it's one guy with a grudge. What I plan to implement is something I've been planning to do for a while, namely a way of people confirming their email addresses by my sending a mail on posting a comment. I plan to do this so it's as effortless as possible, so an simple link to click which sets a cookie on your browser, all subsequent comments can be made without confirmation. I also plan to implement CAPTCHA (well, the stuff Stephen Toub mentioned in his article...). I'm not overly sensitive but I really dislike cowardly personal attacks like I had over the past 24 hours...at least give me a change to know 1. who you are and 2. a chance to discuss your issues outside this blog.
Stephen Toub has
just posted that he's had an
article go live on MSDN which has some really stunning applications of the '
CAPTCHA' technique for proving that people entering data are really human (or really smart animals I guess). This is simply the
most complete article on the topic for ASP.NET I've ever seen! Great work Stephen!
FYI, as usual you can get the 'downloadable' CHM version of MSDN magazine here. Oh, and for furture reference, the url looks like this http://msdn.microsoft.com/msdnmag/issues/04/10/MSDNMag0410.chm so, to get the previous one you would do this : http://msdn.microsoft.com/msdnmag/issues/04/09/MSDNMag0409.chm
OK, I've decided, I want to be an MVP, they seem to get all sorts of cool stuff (plus, BsC, DClinPsych, Msc are getting lonely after my name). So, here's a question to all of those in the know - how do you get to be an MVP (also, does being Scottish specifically exclude you from being an MVP - I don't know of any in my country!)
http://pyre.third-bit.com/blog/archives/000106.html
Has a great story on using a rubber duck as a debugging tool...I'll update this post later as to why this really hits a note with me...
UPDATE: OK, I find this post just nails it as far as 'Essential Equipment' goes for me (well apart from the Chess set...that would involve WAY too much concentration..and the trainers...too lazy). Anyway, the rubber duck...quite often I can get stuck on a particular problem when coding (actually most often whilst debugging) and despite trying just about everything the solution is not forthcoming, my version of a rubber duck is our Technical Director JJ. I find that explaining a problem to someone else can have a pretty much miraculous effect on finding the solution, guess it has to do with reordering the information into a more structured fors, allowing my mind to finally work through a solution...
Ah, I love getting new stuff (even if it technically means I'll be living on Gruel for the next month...). Today I got the ubiquitous
Star Wars Trilogy DVD, a lovely new
Lacie external 205Gb hard drive (which I think was a bit of a bargain at £128.44!) and the
Visual Studio 2005 Beta 1 Refresh DVDs (for which I REALLY have to get one of my machines set up!). I'm also expecting my snazzy
new DVD Rewriter (I waited until now to get one that writes to ALL current formats). So, guess what I'll be doing for the next week
Just reading on
Fritz Onion's blog about
some information he has on IIS7, I have to say this seems really cool. It's always bugged me that ASP.NET was incapable of doing such things as intercepting the response stream and that HttpModules were essentially humbled as a result. Sounds like in IIS7 we'll be able to do all sorts of cool stuff we can't do right now (for example a totally ASP.NET based file uploader
which just isn't possible right now...)
This is a 'remind myself' thing; also because I tend to use this blog as a personal memory 'ting which I search on Google with the "site:www.mostlylucid.co.uk searchterm" syntax. Anyhoo, a fantastic site on BrowserCaps - the thing which ASP.NET uses to decide on what HTML to send to what browsers can be found
here...
This is really nice solution to a particularly thorny problem - namely, repeaters repeat...you can't normally change the template for each row. The problem which this solves for me is the creation of a small survey application where I can use this technique to allow the definition of different row templates based on question type; saves me a whole heap of Server Control hacking! Anyway, again...
article by
Rob van der Veer (cool name!)
Let the crossover continue! left a comment on my old post about HTC inside Mozilla, he points to a post he left in the XULPlanet forum showing a technique to get XUL behaviours running inside of Internet Explorer using a simple HTC behaviour as a sort of interface layer. This is again, pretty cool - and would be even cooler if it could be extended to allow complete translation between all IE HTC behaviours and their XUL equivalent! Anyway, since this is posted on a forum I know nothing abot, I'll repeat the post here:
I've reflected on possibilities offered by famous behavior HTC under IE. I think it would be perhaps possible to interpret a small part of specifications of XUL.
A little sample:
| Code: |
<?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type="text/css" href="xul.css" media="all"?> <window id="example-window" title="Example" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> <label control="some-text" value="Enter some text"/> <textbox id="some-text" value="toto"/> <label control="some-password" value="Enter a password"/> <textbox id="some-password" type="password" maxlength="8"/> <menulist label="Bus"> <menupopup> <menuitem label="Car"/> <menuitem label="Taxi"/> <menuitem label="Bus" selected="true"/> <menuitem label="Train"/> </menupopup> </menulist> </window> |
| Code: |
label{behavior:url(label.htc)} menuitem{behavior:url(menuitem.htc)} menulist{behavior:url(menulist.htc)} menupopup{behavior:url(menupopup.htc)} textbox{behavior:url(textbox.htc)} window{behavior:url(window.htc)} |
| Code: |
<public:htc urn="window"> <public:attach event="ondocumentready" handler="build" /> <public:property name="value" /> <script type="text/javascript"> function build(){this.innerHTML=this.value;} </script> </public:htc> |
| Code: |
<public:htc urn="window"> <public:attach event="ondocumentready" handler="build" /> <public:property name="id" /> <public:property name="label" /> <public:property name="value" /> <script type="text/javascript"> function build() { var option = document.createElement("option"); var style=this.currentStyle; option.setAttribute("id",id); if(this.id!=null){option.setAttribute("id",this.id);} if(this.value!=null){option.setAttribute("value",this.value);} if(label!=null){option.innerHTML=label;} for(var prop in style){option.style[prop]=style[prop];} this.outerHTML=option.outerHTML; } </script> </public:htc> |
| Code: |
<public:htc urn="window"> <public:attach event="ondocumentready" handler="build" /> <public:property name="id" /> <script type="text/javascript"> function build() { var select = document.createElement("select"); var style=this.currentStyle; select.setAttribute("id",id); if(id!=null){ select.setAttribute("id",this.id); select.setAttribute("name",this.id); } select.innerHTML=this.innerHTML; for(var prop in style){ select.style[prop]=style[prop]; } select.style.width="100%"; this.outerHTML=select.outerHTML; } </script> </public:htc> |
| Code: |
<public:htc urn="window"> <public:attach event="ondocumentready" handler="build" /> <public:property name="id" /> <public:property name="label" /> <public:property name="value" /> <script type="text/javascript"> function build() { var optgroup = document.createElement("optgroup"); var style=this.currentStyle; if(this.id!=null){optgroup.setAttribute("id",this.id);} if(this.label!=null){optgroup.innerHTML=this.label;} optgroup.innerHTML=this.innerHTML; for(var prop in style){optgroup.style[prop]=style[prop];} this.outerHTML=optgroup.outerHTML; } </script> </public:htc> |
| Code: |
<public:htc urn="window"> <public:attach event="ondocumentready" handler="build" /> <public:property name="id" /> <public:property name="value" /> <public:property name="type" /> <public:property name="maxlength" /> <script type="text/javascript"> function build() { var input = document.createElement("input"); var style=this.currentStyle; input.setAttribute("id",id); if(value!=null){input.setAttribute("value",value);} if(type!=null){input.setAttribute("type",type);} if(maxlength!=null){input.setAttribute("maxlength",maxlength);} for(var prop in style){input.style[prop]=style[prop];} input.style.width="100%"; input.style.cursor="text"; input.style.borderStyle="inset"; input.style.borderColor="ActiveBorder"; input.style.borderWidth="2px"; input.style.backgroundColor="#FFFFFF"; input.style.paddingLeft="2px"; this.outerHTML=input.outerHTML; } </script> </public:htc> |
| Code: |
<public:htc urn="window"> <public:attach event="ondocumentready" handler="build" /> <public:property name="title" /> <script type="text/javascript"> function build(){window.status=this.title;} </script> </public:htc> |
It's Funny ! Is'nt it ?
The goal of a project like this on isn't to rise Internet Explorer but just to show a little overview to other ones (who haven't got Mozilla Web Browser) the technologies available with Mozilla Framework
Well, I've spent the past week working on an application written in Classic ASP - just a small update before we do a total rewrite in ASP.NET in a few months. I have to say, I am now slow as hell writing VBScript / ASP, I have no idea why, it's like the bit of my brain that's used to structure applications is just not capable of doing it in VBScript any more. I'm slow, inaccurate and really badly motivated working on this thing - and I really don't know why! Ah well, I have at least another week of this stuff to look forward to before I can get back on to 'proper' coding in .NET / C# again...just have to grin and bear it I suppose!
Kent Sharkey posted a link to a study showing how people scan web pages. This is really interesting from a usability perspective as it gives indications as to how to improve the design of your pages to more easily highlight information you want users to take notice of / make the site easier to use. The site also has a bunch of hints on these items as well. The graphic below is one of the most interesting bits to me, shopwing what areas were given what priority on news homepages...

I'm sorry, but
these guys haven't even made one good song - a fairly decent riff in their
first single but the rest of their first album is derivative crap. The
Mercury Music prize is meant to reward innovative music.
Belle & Sebastian or
Snow Patrol are just so much more innovative and original than that bunch of arty farty poseurs...
I never thought the day would come, but reading
weblogs.asp.net is just too cumbersome now. So as of a few minutes ago I've unsubscribed from the main feed. Ah well, it was fun while it lasted! So, how am I going to keep up...simple, I just imported the OPML from weblogs.asp.net into
Bloglines and I can read the whole lot at once. All that will happen is that weblogs.asp.net will use more bandwidth as a result of this...not less! Ah crap, just noticed that Bloglnes doesn't let you view an aggregate of all the feeds in a single folder...time to dig out
Feeddemon again...
UPDATE: Just noticed that the full-text feed is back! Re-subscribed...
OK, so I'm aware the main page was REALLY huge but to be honest, all that's happened now is that the utility of
the page has been reduced...couldn't they have just implemented compression?
Right now on XXX they're selling 'magnetic therapy', they'd be as well selling magic beans. I mean, they're charging £100 for some dumb rotating magnet and claiming real medical benefits for this piece of junk. For a complete review of current research on magnet therapy have a look at this paper . The XXX site does also seem to make some ludicrous claims including 'increasing circulation' - I do notice they claim no real medical benefits and all the language is closeted in 'may' and 'might'. Anyway, for fear of being sued, I use evidence from the following sites as the source of my statements:
http://skepdic.com/magnetic.html
http://www.csicop.org/si/9807/magnet.html
Think of it this way, if magnetic fields had an effect on circulation...why's there no effect in MRI scanners? These little magnets on sale are around 2300gauss - MRI units are around 5000-20000 gauss! COUGH...SNAKE OIL...COUGH...
UPDATE: Umm...yes, after talking to a friend of a legal persuasion I've basically bottled it and decided to remove the names of the companies involved - not because I think their products are any good but because I really don't want the hassle of fending off a libel suit...
It just seems like bloody-mindedness, even their
snazzy new TOC doesn't seem to bother supporting Mozilla based browsers (especially love on the test page - 'just click on the link on the upper left' - in my browser, no link). OK, so I can see the 'use IE' point here (so, trying to force users to use their own browser) but it is REALLY annoying. Especially whn you feel ill (come on people, feel sorry for me, I'm burning up here!)
Scott Mitchell by way of Tosh Meston's blog asks what sites we can't live without...well, 'live' is a bit strong! But sites which I would be irritated if my access to them were denied / limited are (in no particular order)
- Google - my online memory - I take a disturbing amount of pride in my searching prowess!
- Weblogs.asp.net - I just love the main ASP.NET blogs site, lots of informed people
- Gizomdo / Engadget - gadgets, gadgets, gadgets, new, shiny...must be mine!
- BBC News - comparatively unbiased news, seems to provide the most balanced coverage of every event.
- Halifax - I am strangely obsessed with what my money gets up to when it's not being spent by me...
- Bloglines - this is kind of a cop-out, it really amounts to about 50 other sites whos' feeds I need.
- Ebuyer - my own personal geek-porn, how a shopping site should work! (Oh, apart from they've now removed their 'rotating' front-page items - BIG mistake, I don't know how many impulse buys I've made from that page!)
- The Register - biased, poorly informed, addictive - basically the tabloid newspaper of the techie world.
- BBC Weather - umm...it rains a lot in Scotland...gotta see if I need my raincoat!
- DotnetJunkies Blogs - I really like this, much smaller community than the ASP.NET ones, but more esoteric and rapidly becoming more interesting.
- Slashdot - gotta see what rabid idiocy happens there every day...
That's my every day sites...I guess not that many, currently looking for a site which has home remedies for nasosinal pain (I have a sore snoot).
UPDATE: Can't believe I forgot CodeProject!
Well, I have a rotten cold, thought it was getting better so I went to watch the Edinburgh Festival Fireworks; which is what the images below are from, there's a bit of the famous 'firework waterfall' and general banginess- click for bigger versions. Well, it got a little damp (it was raining, not from overexcitement
) ann I now have the cold which I thought I was gettting rid of making a none too subtle reappearance. Typically I used all my painkillers for the early stages and am now having to suffer from vicious sinus pain - choice is, venture out to the all night store and suffer more pain for a short period or try to suffer though 'til morning til the shop round the corner opens...the agony of choice! Anyway, whatever happens I don't forsee much sleep overnight...bugger...


Cool, Mark Anders (or someone claiming to be Mark) just replied to an old post of mine:
Actually, I was at Microsoft untill exactly the date of Bob's, Aug 13th, when I joined Macromedia. Scott and I started the ASP.NET team back in Jan 98, and I ran it and the .NET Framework team until Dec, 2002. I then started a project called "Nautilus" to ... well I probably shouldn't say! :-) I'm now at Macromedia and really love it. While I can't really say what I'm working on at this point, it's a lot of fun and I think will be very interesting! :-)
Thanks for you interest!
Mark
Incidentally, the *Scott* is not me :-), rather Scott Guthrie. Ok, so who knows,
1. if this is really Mark (call me suspicious :-)) - his IP address is in San Francisco though...which makes sense...
2. What was / is "Nautilus"
3. What's he up to at Macromedia (should I be buying Macromedia shares?)
What's happening to the ASP.NET team? Well, technically Mark wasn't on the ASP.NET at the end but with Rob leaving then Mark things are looking pretty interesting.
This is a really great post from Chris Taylor on a method of rendering a LCD style hit counter using ASP.NET. Chris mentions a bug using the Image.Save method for PNGs - which is a bit wierd...Anyway, nice code, nice post...nice!
I have 6 GMail invites going spare, leave a comment with your email address to get one...first come, first served!