Tim

Footprints in the snow of a warped mind

August, 2007

Where to find me

Flickr Icon  Twitter Icon  Linked In Icon  FaceBook Icon  Windows Live Alerts Butterfly  RSS 2.0 

The Site Doctor is Hiring!

Enjoy what you read here?
Think you can do better?
Join our team and get paid
up-to £35,000.
Apply now.

Tag Cloud

AJAX (4) Analysis (3) ASP (6) ASP.Net (59) Error Reporting (4) Web Service (2) WSDL (1) Atlas (2) Azure (1) Born In The Barn (1) Business (95) Business Start-up Advice (37) Client (17) Expanding Your Business (24) Recruitment (1) C# (25) Canoeing (4) Canoe Racing (5) Cheshire Ring Race (5) Racing (2) Training (4) Christmas (1) CIMA (1) Cisco (1) 7970G (1) CMS (1) Code Management (1) Cohorts (4) Commerce4Umbraco (1) Content (1) Content Management (1) Content Management System (1) CSS (4) dasBlog (5) DDD (2) DDDSW (1) Design (12) Icons (1) Development (28) Domain Names (1) eCommerce (13) Email (1) Employment (2) Festive Sparkle (1) General (39) Christmas (6) Fun and Games (11) Internet (22) Random (46) RX-8 (8) Git (2) Google (1) Google AdWords (1) Google Analytics (1) Hacking (1) Helpful Script (3) Home Cinema (2) Hosting (2) HTML (3) IIS (11) iPhone (1) JavaScript (5) jQuery (2) LINQPad (1) Marketing (6) Email (1) Multipack (1) MVC (3) Networking (3) Nintendo (1) Nuget (1) OS Commerce (1) Payment (1) Photography (1) PHP (1) Plugin (1) PowerShell (3) Presentation (1) Press Release (1) Productivity (3) Random Thought (1) Script (2) Security (2) SEO (6) Server Maintenance (7) Server Management (12) Social Media (2) Social Networking (3) Experiment (1) Software (11) Office (5) Visual Studio (14) Windows (6) Vista (1) Source Control (2) SQL (13) SQL Server (19) Starting Something New (2) Statistics (2) Stored Procedure (1) Sublime Text 2 (1) SVN (1) TeaCommerce (1) Testing (2) The Cloud (1) The Site Doctor (140) Turnover Challenge (1) Twitter (3) uCommerce (20) Umbraco (37) 2009 (1) 2011 (1) Useful Script (6) Virtual Machine (1) Web Development (72) WebDD (33) Wii (1) Windows Azure (1) XSLT (1)

Blog Archive

Search

<August 2014>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
31123456

Recent Comments

Blog Archive

Various Links

Google+

Blogs I Read

[Feed] Google Blog
Official Google Webmaster Central Blog
[Feed] Matt Cutts
Gadgets, Google, and SEO
[Feed] Ol' Deano's Blog
My mate Dean's blog on my space, equally as random as mine but not off on as much of a tangent!
[Feed] Sam's Blog
Sam is one of my younger brothers studying Product Design and Manufacture at Loughborough, this is his blog :) Enjoy!

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

newtelligence dasBlog 2.2.8279.16125

Send mail to the author(s) Email Me (Tim Gaunt)

© 2014 Tim Gaunt.

Sign In

    # Friday, August 24, 2007

    The Controls collection cannot be modified because the control contains code blocks

    Friday, August 24, 2007 10:49:56 AM (GMT Daylight Time, UTC+01:00)

    Server Error in '/' Application.


    The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

    Source Error:

     

    Line 132:                        metaKey.Name = "keywords";
    Line 133:                        metaKey.Content = p.MetaKeywords;
    Line 134:                        this.Page.Header.Controls.Add(metaKey);
    Line 135:                    }
    Line 136:                    if (!String.IsNullOrEmpty(p.MetaDescription))


    Source File: a:\xyz\ContentHandler.aspx.cs    Line: 134

    Stack Trace:

     

    [HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
       System.Web.UI.ControlCollection.Add(Control child) +2105903
       ContentHandler.Page_Load(Object sender, EventArgs e) in a:\xyz\ContentHandler.aspx.cs:134
       System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
       System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
       System.Web.UI.Control.OnLoad(EventArgs e) +99
       System.Web.UI.Control.LoadRecursive() +47
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061


    Version Information: Microsoft .NET Framework Version:2.0.50727.832; ASP.NET Version:2.0.50727.832

    Another day, another issue ;)

    This had me going around in circles for a while until I realised what it was, if you're getting this error you can bet your bottom dollar that you have <%= %> somewhere in your page's header -furthermore I'd hazard a guess that you've got it in some JavaScript to reference an ASP.Net control on the page- and then you're trying to add a control to the header programmatically (or a custom control from someone like Telerik is trying to). Am I right1?

    1 I'm not allowed to ask you to so I won't, but if I was right, then spend that bottom dollar clicking on one of the Google Ads :P

    I can't tell you exactly why this occurs but my understanding of it is that ASP.Net can't re-create the header if it has Response.Write somewhere in the header (<%=) -most likely due to when the header is created it's not available (will look into it). No doubt you want to know the fix?

    The Fix
    The fix is simple, remove the inline code blocks and JavaScript and move it to your code behind i.e.:

    string _manageSearch = String.Format( @" 
            function ManageSearch(){{
                    var lbl = document.getElementById(""lblFindAGift"");
                    var txt = document.getElementById(""{0}"");
                    var btn = document.getElementById(""{1}"");

                    .Do Something with it..

            }}",

            txtSearch.ClientID);

    this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "ManageSearch", _manageSearch, true);

    Remember: You need to escape the curly brackets otherwise you will get a "String.Format- Exception of type System.Web.HttpUnhandledException was thrown"

    Update: Thanks to Julian Voelcker for sending me this alternative "fix" for the problem, can't say I like it though ;) basically instead of using <%= ... %> you would write the databinding expression of: <%# ... %>

     

    Don't forget to follow me on Twitter.

    Understanding email server connection checks

    Friday, August 24, 2007 5:59:42 AM (GMT Daylight Time, UTC+01:00)

    One of the reasons I'm fanatical about Rackspace as a hosting partner is that if you're unsure about something, you know you're able to ask an expert and get a top-notch response to your quandary.

    I was recently speaking with another host who was talking about greylisting their emails -in short this is the process of rejecting the first email from a given email address/server and waiting for it to be (automatically) resent by the server later as unlike genuine email servers, most spam servers do not try to re-send an email if it's rejected by a server. We're not able to greylist our emails so I thought I would check that our spam filter settings were up-to-date.

    The guys at Rackspace had a look through our spam filter settings and recommended we disabled the statistical filters as they were somewhat outdated technically and increase our connection checks -more importantly, deleting the email after it fails a number of checks. Historically I've been adverse to deleting emails on the server as there's no way to recover them so I asked how accurate connection checks were and thought I would share their easy-to-understand response about what the connection checks do.

    Tim,

    In order to understand the unlikelihood of false positives for this case, you must first understand what each check does.

    Verify HELO/EHLO domain.

    This will create a test in which the domain passed during the HELO/EHLO is used to perform a DNS query to verify that the domain specified has an A record or an MX record. (All valid domains should have a valid HELO/EHLO domain, only mis-configured and spam mail servers fail this test)

    Perform Reverse DNS Lookup for Connecting Server.

    This will create a test in which the IP address of the connecting server is used to perform a reverse DNS lookup to determine the domain name. If a domain has a valid PTR record, the message is accepted. (Not all valid domains have a PTR record)

    Verify MAIL FROM Address.

    This will have the "From" address of the connecting server verified for each message to ensure that the user is a valid user on the mail server. If the user or server does not exist, the message is identified as spam. (This is a definite give-away that the message is a spam message).

    We can then set the delete threshold to 4. The "Delete message after X matches" will delete the message after it matches 3 of the above rules and/or black lists. This will almost guarantee that the message is spam. If the message fails all Verification checks, it is spam. If the message fails 2 connection checks and a DNS Blacklist check, it is spam. If an email fails both DNS Blacklist checks, and 1 verification check, it is spam. You are pretty much guaranteed that a message is spam. If you want to make extra sure, you could set the delete threshold to 4 that way it will have to fail all verification checks and one blacklist, or both blacklists and two verification checks.

    Thank you,

    Roberto M Chapa

     

    Don't forget to follow me on Twitter.

    # Wednesday, August 22, 2007

    Amazon -unbelievable customer service

    Wednesday, August 22, 2007 9:53:08 PM (GMT Daylight Time, UTC+01:00)

    Stacey bought me a Canon IXUS 950 IS for my birthday which needless to say I was more than chuffed to receive, it's a fantastic camera with enough bells and whistles to make it more than just a happy snappy camera but not too many to make it cumbersome to transport so you can ensure you have it to hand when that un-missable shot is coming.

    Problem was, on the weekend it developed a fault -Canon's dreaded E24 error. It's predecessor lasted about 4 years before a rainstorm when it decided to start (understandably) complaining for a while but the IXUS 950 IS hasn't had any (recent)1 abuse so I called Amazon fearing the worst but hoping they would replace it as this would appear to be a software related fault.

    1 About a week after I got the camera I did drop it but that was mid July.

    I first of all emailed them using their online panel as it was out of it's 30 day no-quibble return period but didn't get a response. A little inpatient I decided to call them yesterday and I spoke to a very helpful representative named "Donncha" who assured me that despite my mishap with dropping it there should be no issues in returning it no offence Donncha but I've heard that one before so I didn't hold my breath. He told me a courier would come and collect the camera tomorrow (today) and a replacement would be with me in 3-4 days.

    A little later I received -what I assumed was- a collection email saying Royal Mail would be around at some point, I wasn't expecting what happened next. At approximately 10am our usual Royal Mail parcel guy arrived to collect the camera, then, about 5minutes later, another parcel delivery man arrives and drops off the replacement!

    I have to take my hat off to you Amazon in this instance, that's superb customer service!

     

    Don't forget to follow me on Twitter.

    Amazon -unbelievable customer service
    Useful Links:  #  digg it!  del.icio.us  Technorati  email it!  Post CommentsComments [1]  Trackback LinkTrackback
    CategoriesTags: Business | Random

    String.Format- Exception of type System.Web.HttpUnhandledException was thrown.

    Wednesday, August 22, 2007 9:43:12 PM (GMT Daylight Time, UTC+01:00)

    Type
    System.FormatException
    Message
    Exception of type 'System.Web.HttpUnhandledException' was thrown.
    StackTrace
    at System.Text.StringBuilder.FormatError()
    at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
    at System.String.Format(IFormatProvider provider, String format, Object[] args)
    Error Line
    0

    Just got that message (or at most "Exception of type 'System.Web.HttpUnhandledException' was thrown")? Puzzled? I was the first time I got it, I've been meaning to post about it for quite some time now so seeing as I got it again today I took the hint.

    The error is horrifingly obvious when you know about it, in short, you've no doubt got some code that looks like this:

    String.Format("<html><head><style type=\"text/css\">body{color: #fff;}</style><body>...");

    Can you spot it now? Notice your style declaration is using the curly brackets? Basically String.Format is interpreting that as a placeholder i.e. {0} and is throwing a wobbly.

    The solution is simple too, just replace all opening/closing brackets with two i.e:

    String.Format("<html><head><style type=\"text/css\">body{{color: #fff;}}</style><body>...");

    I hope that helps someone out there :)

    P.S. Watch out for methods that use String.Format as they may catch you out in the same way -i.e. Subject of System.Net.Mail.MailMessage

     

    Don't forget to follow me on Twitter.

    # Sunday, August 19, 2007

    Chip and Pin -is it really more secure?

    Sunday, August 19, 2007 10:59:43 AM (GMT Daylight Time, UTC+01:00)

    We've officially been using Chip and Pin in all stores since around February 2007 in the UK which has made life a lot easier in many ways but ever since it's introduction, I for one have had concerns over the claims that it's safer. I agree that it is (or was) harder to find out someone's pin number but has it made shop assistants more complacent?

    Stacey and I have a joint Egg Card -I know, what WAS I thinking ;), anyway, these two cards look identical and even had the same pin number and as a result, we recently got them mixed up. I can't say for sure when it was we got them swapped around but one thing for sure is that it was a good couple of months ago. Ever since, we've both been using the wrong card without being questioned, at a guess, I think this has gone on for around 4 months and I only noticed the other day when I looked down and read the name on the card when I was paying online.

    This for me is pretty concerning, ok it's because I know the pin, the shop assistant assumes I'm the card holder and doesn't check the name (which the used to when they were forced to check the signature -if they bothered checking that of course ;)).

    I think it's also easier to find out the pin too as people aren't overly cautious about entering in their number, I've even seen an old lady in a wheelchair type her pin in on the terminal which was on the desk while she remained lower down in the wheelchair, allowing anyone within about 10m to read what she was typing in. She then promptly put her card back in to her bag and hung it over the back of her wheelchair -where any unscrupulous person could come along and "borrow" the card. It's not just the elderly however, even the young allow other people to read the pin.

    I would be interested to know the statistics in crime reduction, I wonder if they're as high as the government were predicting or whether these predictions failed to include the main weak link in the system -us.

    On the whole however, it has made life easier and I like Chip and Pin despite these (human) errors, to an extent I think it has made it harder for the criminal to steal (though before he had to learn the signature) but I think people need to be more cautious.

     

    Don't forget to follow me on Twitter.

    Chip and Pin -is it really more secure?
    Useful Links:  #  digg it!  del.icio.us  Technorati  email it!  Post CommentsComments [0]  Trackback LinkTrackback
    CategoriesTags: Business | General
    # Thursday, August 16, 2007

    Quote of the day

    Thursday, August 16, 2007 5:57:54 AM (GMT Daylight Time, UTC+01:00)

    "Charge less and just do it quicker" -or- "Charge less, just spend less time on it"

    That's what I got from someone that (infrequently) passes me work when I quoted him on some development yesterday. It sums some clients up though, they think you can do the work required -and- get the results by doing less and as for working faster -you can forget that, do they not think we go as fast as possible so we can move onto the next project sooner?

    Made me smile so I thought I'd share :)

     

    Don't forget to follow me on Twitter.

    Quote of the day
    Useful Links:  #  digg it!  del.icio.us  Technorati  email it!  Post CommentsComments [0]  Trackback LinkTrackback
    CategoriesTags: Client | Random
    # Tuesday, August 14, 2007

    OS Commerce error: 1062 - Duplicate entry '' for key x

    Tuesday, August 14, 2007 11:14:15 AM (GMT Daylight Time, UTC+01:00)

     What am I doing messing with OS Commerce I hear you cry? Well one of our SEO clients (Florame Organic Aromatherapy) uses a very hacked version of OS Commerce as it's engine and as dire as it is, if it ain't broke don't fix it.

    Today I came across (another) error with one of the modules that was installed -the dreaded "1062 - Duplicate entry" error. After a little digging, it wasn't too hard to diagnose, unlike many people (see: 1062 - Duplicate entry fix) this error was being thrown in the product details page. It turns out that since installing the new Froogle feed, the UPC data wasn't being updated, the fix is for you to either remove it and create the UPC by combining i.e. the product code and model number on the fly or to simply validate the new UPC code field is populated.

    Easy :) -I hope I saved you trawling through the OS Commerce forums.

     

    Don't forget to follow me on Twitter.

    # Wednesday, August 08, 2007

    'debug' is undefined with Microsoft AJAX release and TextChangedBehavior.js

    Wednesday, August 08, 2007 6:20:47 AM (GMT Daylight Time, UTC+01:00)

    As with my previous post, we upgraded the AJAX framework on the weekend which broke a few things, but one control in particular that broke was our TextChangedTextBox which is based on Pete Kellner's timed postback control. Since updating we were receiving a "'debug' is undefined" error on line 1409 (which was in one of the JavaScript include files).

    Having had this issue before I updated the TextChangedBehavior.js but that didn't sort it, I have the latest version of the Futures on the server too so I was lost. Turns out I had an old version of the AJAX Futures DLL within the Bin folder of the project.

    So as with my post on the ASP.Net forums before -make sure you update your AJAX Futures when updating your Microsoft AJAX framework!

     

    Don't forget to follow me on Twitter.

    # Monday, August 06, 2007

    Server cannot modify cookies after HTTP headers have been sent (RoleManagerModule.OnLeave)

    Monday, August 06, 2007 1:52:08 PM (GMT Daylight Time, UTC+01:00)

    Over the weekend we had to upgrade the server's version of ASP.Net AJAX which went fine until this morning when we started receiving the error "Server cannot modify cookies after HTTP headers have been sent."

    Luckily this wasn't bubbled up to the UI but incase other people are getting the error I thought I would share the fix. The error is apparently a known error with ASP.Net AJAX and the RolesManager. To fix the error all you need to do is add the following to your RolesManager web.config node:

    cacheRolesInCookie="false"


    The full error message was

    Message:
    Server cannot modify cookies after HTTP headers have been sent.

    StackTrace:
    at System.Web.HttpCookieCollection.Add(HttpCookie cookie)
    at System.Web.Security.RoleManagerModule.OnLeave(Object source, EventArgs eventArgs)
    at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

     

    Don't forget to follow me on Twitter.