Recent Updates RSS Toggle Comment Threads | Keyboard Shortcuts

  • Steve Lydford 5:00 pm on October 20, 2013 Permalink | Reply
    Tags: Clean Code   

    Obfuscation as standard 

    Looking through some code recently I came across a snippet which looked similar to this:

    Take a look at those comments! This is an example of a problem I see regularly in software projects – obfuscation by coding standards.

    In this instance they were inserted by StyleCop & Resharper, but just about every language has its own static analysis and coding standards tools, especially those used for “enterprise” level application development. Now imagine those comments across every class, field, property and method in an application. The result is worse than useless – it actually makes it harder to read and maintain.

    On a previous project I saw a class file which contained around 850 lines, of which over 500 were StyleCop enforced code comments of a similar quality to those shown in the snippet above. What you end up with very quickly is the software equivalent of this:




    Many of you will be thinking that a good developer should not accept the default comments inserted by the tooling. I totally and wholeheartedly agree with you. A good developer should be writing clean code and commenting only where it is absolutely necessary. Make the comments in your code an exception, so that the next person who looks at it actually notices where you have left them a useful note and doesn’t just miss it in a sea of pointlessness and vertical noise.

    And it is not just code comments that can have a detrimental effect on the readability of the code base. Many of the other rules enforced by static analysis tools can make code unnecessarily verbose to the point of obfuscation or force the original developer to present it in a less natural reading order, for example.

    Blind adherence to static analysis and coding standards can be incredibly counter-productive. Now, no dev lead is going to set out to do this on purpose. More often than not it is done mistakenly in the pursuit of quality and standards. Sometimes however, I am certain that this is done to give themselves a quiet life – to assure their managers that processes are in place to ensure quality code without giving themselves too much extra work – but the results can be catastrophic for readability and maintainability, thereby actually making the solution worse than if they had never introduced them in the first place.

    Code quality is the responsibility of every developer – but is it the senior/lead developers job to review it and guide and mentor more junior team members if there are issues with their work. While they do have their uses, delegating this responsibility solely to a static analysis tool is no replacement for a one-to-one code review.

    Digg This
    Reddit This
    Stumble Now!
    Buzz This
    Vote on DZone
    Share on Facebook
    Bookmark this on Delicious
    Kick It on
    Shout it
    Share on LinkedIn
    Bookmark this on Technorati
    Post on Twitter
    Google Buzz (aka. Google Reader)
    • シチズンレディース 8:18 am on November 6, 2013 Permalink

      トリーバーチ トート

    • mobile games 2:45 pm on April 15, 2014 Permalink

      No matter if some one searches for his essential thing, thus he/she wants to be
      available that in detail, therefore that thing
      is maintained over here.

    • watch walk of shame online 6:34 pm on April 23, 2014 Permalink

      My brother recommended I might like this web site.
      He was totally right. This post truly made
      my day. You cann’t imagine just how much time I had spent for this info!

    • million dollar arm download 11:10 pm on April 26, 2014 Permalink

      Nice post. I learn something new and challenging on
      websites I stumbleupon every day. It will always be useful to
      read articles from other authors and practice something from other sites.

    • cheat codes for black ops 2 2:43 pm on May 13, 2014 Permalink

      After all, badly-written guidelines prevents or perhaps hinder some tasks
      or actions, plus they certainly reflect an awful picture of both the application developers as well as the
      development firm. * enhanced corporate efficiency and new communications clarity;.
      Do you should check within the calls, the spot,
      the messages, quite a few spy softwares for cellular phones do
      all of this, but the top spy cell phone software are people that basically answer your queries (Where is
      my husband.

    • game of thrones season 4 6:06 pm on May 20, 2014 Permalink

      Quality articles or reviews is the main to attract the users to go to see the
      web site, that’s what this site is providing.

    • moto apparel 6:58 pm on June 30, 2014 Permalink

      An impressive share! I have just forwarded this onto a colleague
      who was doing a little homework on this.

      And he actually ordered me dinner due to the fact that I stumbled upon it for him…

      lol. So let me reword this…. Thank YOU for the meal!!

      But yeah, thanx for spending the time to talk about this matter here on your site.

    • Johng269 11:49 am on July 1, 2014 Permalink

      Your goal is to breed all the different dragons available to you gaefckaabkkf

    • Jamel 9:45 pm on July 4, 2014 Permalink

      you are actually a excellent webmaster. The web site loading pace is amazing. It sort of feels that you’re doing any unique trick. In addition, The contents are masterpiece. you’ve performed a great task on this topic!

    • EbonyGesy 3:46 pm on July 31, 2014 Permalink

      Hellow .
      Superbly here. I liked it!
      Keep up the good work! :)

    • Lane 12:36 pm on August 9, 2014 Permalink

      Very shortly this site will be famous amid all blogging viewers, due to it’s pleasant content

    • best mattress 2014 10:10 am on August 10, 2014 Permalink

      You actually make it appear so easy with your presentation but I to find this matter to be actually something which I believe I would by no means understand.
      It sort of feels too complex and extremely large for me.
      I am looking ahead for your next post, I’ll attempt to get the
      hang of it!

    • carte psn gratuit 6:04 pm on August 21, 2014 Permalink

      It’s amazing in favor of me to have a website, which
      is good in support of my know-how. thanks admin

    • 10:17 am on August 26, 2014 Permalink

      What’s up it’s me, I am also visiting this web site daily, this web site is in fact nice and the people are in fact sharing pleasant

    • Suddenly slimmer you 1:00 pm on September 1, 2014 Permalink

      Hi there to every body, it’s my first visit of this webpage;
      this blog contains amazing and actually fine material designed for readers.

    • garcinia flood pro extractor 1:25 pm on September 1, 2014 Permalink

      I do believe all the ideas you have presented to your post.
      They are very convincing and can certainly work.
      Still, the posts are too brief for starters. May you please prolong them
      a little from next time? Thank you for the post.

    • where to buy garcinia 8:17 pm on September 1, 2014 Permalink

      It’s a pity you don’t have a donate button!
      I’d certainly donate to this brilliant blog! I guess for now i’ll settle for book-marking and
      adding your RSS feed to my Google account. I look forward to fresh updates and will
      talk about this site with my Facebook group. Chat soon!

    • port royal sofa sets 10:49 am on September 3, 2014 Permalink

      Awesome web site, previously been looking forever for tips on the perfect rattan furniture for
      our home and in our garden. The website really helpedgreat
      blog some great info here

    • garcinia plus capsules 5:11 pm on September 5, 2014 Permalink

      Hi, this weekend is good in support of me, for the reason that this time i am reading this wonderful educational post here at my residence.

    • yeast free diet plan 1:13 am on September 6, 2014 Permalink

      Every weekend i used to go to see this site, as i want enjoyment, for
      the reason that this this site conations actually pleasant funny information too.

    • Encourage Weight Loss 5:27 am on September 6, 2014 Permalink

      Your style is so unique in comparison to other people I have read stuff from.
      I appreciate you for posting when you have the opportunity,
      Guess I will just book mark this web site.

    • Brigida 8:16 pm on September 6, 2014 Permalink

      Thanks for one’s marvelous posting! I seriously enjoyed reading it, you might be a great author.I will
      ensure that I bookmark your blog and will eventually come back someday.
      I want to encourage you continue your great posts, have a nice day!

    • Thelma 2:30 pm on September 9, 2014 Permalink

      Had been actually looking for just a traditional shower enclosures
      before I came across this web site, wouldn’t have any idea there were such a thing
      as a ‘steam shower enclosure’, fantastic, will probably just
      may have to buy one

    • 9:41 am on September 15, 2014 Permalink

      Fantastic website, just lately been scouting forever and a day
      for ideas on the best rattan furnishings for our home and in our back garden. This website sincerely helpedgreat blog some great info here

    • Bradford 3:37 am on September 20, 2014 Permalink

      Touche. Great arguments. Keep up the amazing spirit.

    • Roseanna C. Alber 5:34 am on September 20, 2014 Permalink

      Undeniably believe that which you said. Your favorite reason seemed to be on the net the easiest thing to be aware of.
      I say to you, I certainly get annoyed while people think
      about worries that they plainly do not know about.

      You managed to hit the nail upon the top and defined out the
      whole thing without having side effect , people could
      take a signal. Will probably be back to get more. Thanks

    • Roscoe 6:17 pm on September 20, 2014 Permalink

      Hey there! This is kind of off topic but I need some help from an established blog. Is it hard to set up your own blog? I’m not very techincal but I can figure things out pretty quick. I’m thinking about creating my own but I’m not sure where to start. Do you have any points or suggestions? With thanks

    • Jefferey 11:40 pm on September 20, 2014 Permalink

      This paragraph is really a nice one it assists new web people, who are wishing in favor of blogging.

    • Bernadette Q. Braver 3:28 pm on September 23, 2014 Permalink

      Simply desire to say your article is as surprising.

      The clearness on your put up is simply excellent and i could think you are a professional in this subject.
      Well together with your permission allow me to seize your RSS feed to stay updated with forthcoming post.

      Thanks 1,000,000 and please continue the enjoyable work.

    • Lasonya T. Mahon 7:12 pm on September 23, 2014 Permalink

      I read this paragraph fully regarding the difference of most up-to-date and preceding technologies, it’s remarkable article.

    • Estrella A. Ernspiker 2:47 am on September 24, 2014 Permalink

      Pretty nice post. I just stumbled upon your weblog and wished to say that
      I’ve truly enjoyed surfing around your blog posts.
      After all I will be subscribing to your feed and I hope you write again very soon!

    • UX 4:14 am on September 24, 2014 Permalink

      My partner and I absolutely love your blog and find many of your post’s to be exactly I’m looking for. can you offer guest writers to write content for you? I wouldn’t mind publishing a post or elaborating on most of the subjects you write in relation to here. Again, awesome site!

    • RK 7:33 am on September 24, 2014 Permalink

      Quality articles or reviews is the main to be a focus for the visitors to pay a quick visit the site, that’s what this web page is providing.

    • Toddler swimwear 12:26 pm on September 25, 2014 Permalink

      Having read this I believed it was extremely informative.

      I appreciate you spending some time and effort to put this content together.
      I once again find myself personally spending way too much time both reading and posting comments.
      But so what, it was still worth it!

    • Garden sheds direct 5:27 pm on September 25, 2014 Permalink

      I’m no longer positive where you are getting your info, but good topic.

      I needs to spend some time finding out much more or working out more.
      Thank you for excellent information I was in search of this information for my mission.

    • Sandy B. Joeckel 6:29 am on October 5, 2014 Permalink

      What’s up to every single one, it’s really a pleasant
      for me to pay a quick visit this website, it consists of valuable Information.

    • doulci 10:51 pm on October 6, 2014 Permalink

      This is very interesting, You’re a very skilled blogger.
      I’ve joined your rss feed and look forward to seeking more of your great post.
      Also, I’ve shared your site in my social networks!

    • Concepcion 6:21 pm on October 7, 2014 Permalink

      Hello there! This is my first comment here so I
      just wanted to give a quick shout out and tell you
      I truly enjoy reading through your posts. Can you suggest any other blogs/websites/forums that deal with the same topics?
      Thanks for your time!

  • Steve Lydford 12:25 pm on October 13, 2013 Permalink | Reply
    Tags: Estimation, Planning   

    Guess why it’s called an estimate? 

    There is an old saying in the Army which is often wheeled out when asking for a new issue of kit from a Colour Sergeant who likes to keep his shelves neat, catalogued and well stocked with shiny things – “The Stores are for storing. If it I was meant to give the kit out it would have been called ‘The Issues’”.


    26Montel Military Smart Shelf Image0149_Low Res


    I am reminded of these frustrating exchanges whenever I hear of a developer being berated for failing to meet an estimate, by a Project Manager who is trying to keep his burn-down chart neat, well ordered and ‘toeing the line’. An estimate is just that, an estimate. It is the developer’s best guess at how long this task will take, not an exact timeframe for delivery.

    I am just waiting for the day I hear a developer turn around the words of my grumpy old Colour Sergeant and say back to the Project Manager -  “It’s called an estimate because it is one. If it was meant to be definitive it would be called an ‘Exact’”.



    I don’t want to beat up too much on Project Managers here. It is a tough job and, if I’m honest, not one I particularly relish when I am asked to do it from time to time. The PM is always under pressure to predict an accurate date for delivery and the only way she can achieve this is by working from the estimates given to her by the development team. Remember, ‘time is money’, and estimation is all about time…

    The problem lies in the reliability of the estimates as a whole; as long as the overall estimate for all tasks within a delivery timeframe is reasonably accurate, then it doesn’t matter so much when some overrun and some come in short.

    Reliable estimation comes down to the use of skill and experience and requires the developer to give it the proper amount of thought. A ‘finger in the air’ SWAG1 is very different to a properly considered estimate. It is one of the signs of an experienced, professional developer to be able to give reliable estimates.


    1 Scientific Wild-Assed Guess

    Digg This
    Reddit This
    Stumble Now!
    Buzz This
    Vote on DZone
    Share on Facebook
    Bookmark this on Delicious
    Kick It on
    Shout it
    Share on LinkedIn
    Bookmark this on Technorati
    Post on Twitter
    Google Buzz (aka. Google Reader)
    • Nicholas Stein 4:32 pm on October 13, 2013 Permalink

      No programming task except the very rote boring horrible just-code-what-I-tell-you-to kind can be accurately estimated. There is always what I call a “car keys” problem.

      My wife and I are going out and I cannot find my car keys. She says, well when are you going to find them?

      You see the problem. In a creative programming environment, which we all aspire to, there is always a problem where you do not know when you are going to solve the problem. Sometimes you have to find the right library for the job. Sometimes you have to find the right combination of techniques that will do the job. Sometimes you just have to wait for the library publisher to add this new feature you have requested.

      You do not know when you will find your car keys until you find them. I have a magic pink rock that helps me find things. It is the best way.

  • Steve Lydford 12:44 am on January 31, 2013 Permalink | Reply

    YAGNAC – Why we should all be building sheds… 

    “… it is simplicity that is difficult to make.” – Bertholdt Brecht

    Developers are creative people; we love to build stuff. We all spend our days, and sometimes our nights too, building stuff. Building stuff is what we do best, often we just can’t help ourselves.

    And therein lies the problem. Let me say it again:

    “often we just can’t help ourselves.”


    How often have you seen code-bases where developers have been let loose to just build “stuff”? This can manifest itself in any number of ways; huge amounts of abstraction, nightmarish levels of inheritance or code which has been made ridiculously generic in the name of re-use, to name but a few.

    Blindly following “good software engineering principles”1 can lead to some horribly unreadable and unmaintainable code. Take the “Don’t Repeat Yourself” principle for example. We all know that good code is DRY, right? But the key to this principle is the avoidance of repetition. The clue is in the name; if there is no repetition, it doesn’t apply. Trust me, you will know when a piece of code needs to be DRY – it will happen just at the point you are going to repeat yourself.

    Remember, it is called “refactor”, not “pre-factor”.

    Let’s spend a moment thinking about another prime cause of unreadable and unmaintainable code – unnecessary implementation of design patterns. Now don’t get me wrong, design patterns can be very useful aids to software development. But they are just that, an aid. Patterns should be implemented when a need for them has been positively identified, not because someone once told you, “that’s the way it should be done”.

    In fact, take one of the most common design patterns – Inversion of Control. Overuse of IoC/Dependency Injection can lead to code which is horrendously difficult to maintain and debug. .NET developers who have encountered this pattern will no doubt have come across this, infamously hard to debug, little beauty:

    No parameterless constructor defined for this object.

    Many of you will have used, or at least be aware of StructureMap. It is a well-regarded Dependency Injection / Inversion of Control tool for .Net that can be used to improve the architectural qualities of an object oriented system by reducing the mechanical costs of good design techniques”. However, a brief scan of the StructureMap home page itself reveals some useful guidance:

    Do not use StructureMap if an application or process requires little flexibility. The abstraction and indirection afforded by StructureMap is unnecessary and even harmful in simpler systems or processes. 

    DI should stand for Dependency Injection, not Developer Indirection.


    I am sure we are not alone. Imagine giving a building architect the following brief: “I just got a great new lawnmower. I would like you to design me a great building to go with it”. That is it; no budget, no use cases, no specification of building materials, no sort of high-level design, no other requirements. If the architect constructed the building in the same way that much software is built you could easily end up with something like this:


    There can be no doubting the skill of the architect. After all, it is a beautiful, classic design, built from the finest materials by master craftsmen. However, it is slightly over-the-top if the “great building” you wanted was one in which you simply intended to store your lawnmower and nothing more. The optimal design would probably look more like this:


    The architect’s design, while it would amply fulfil the function, would be immeasurably more complex, take much longer to construct, be harder to maintain, take up way more room and be vastly more expensive.

    So who’s fault would this be? Is it your fault, or the fault of the architect? Well, the simple answer is both – you for not stipulating sufficient constraints and the architect for building way too much stuff. But, in the same way as software developers, architects just love to build stuff.

    So how does this apply to software projects? It is imperative that the people responsible for the solution design provide a clear definition of requirements and constraints, and the people responsible for the implementation of the design (i.e. the software developers) need to learn to build sheds where a shed is all that is required.

    Simply put: YAGNAC – You Ain’t Gonna Need A Cathedral.

    Further reading:

    Reuse Myth – can you afford reusable code? – Allan Kelly

    Cargo cult programming – Wikipedia

    Why I Hate Frameworks – Joel Spolsky


    1 to be read in a high-pitched nasally whine

    Digg This
    Reddit This
    Stumble Now!
    Buzz This
    Vote on DZone
    Share on Facebook
    Bookmark this on Delicious
    Kick It on
    Shout it
    Share on LinkedIn
    Bookmark this on Technorati
    Post on Twitter
    Google Buzz (aka. Google Reader)
    • learn here solar powered attic fan 5:30 am on July 2, 2013 Permalink

      Fine way of explaining, and fastidious paragraph to obtain data
      regarding my presentation subject, which i am going to present in institution
      of higher education.

    • chicago web developer 6:02 am on July 17, 2013 Permalink

      I like what you guys tend to be up too. This sort of clever work and coverage!

      Keep up the amazing works guys I’ve you guys to blogroll.

    • Kaley 10:45 pm on January 8, 2014 Permalink

      You can observe the latest weather updates simply by
      taking a look into your phone’s home screen, where it automatically posts weather info,
      and all without having to launch the application. Virus Barrier
      X5 is often a popular virus scanner readily available for Mac computers.
      The free Lyrics Search app is available at the Android Market.

    • NAWIJARKI jednobębnowe 4:46 am on June 3, 2014 Permalink

      At this time I am going away to do my breakfast, afterward having my
      breakfast coming yet again to read more

    • maszyny 7:17 am on June 16, 2014 Permalink

      I think this is one of the most vital information for me.
      And i’m glad reading your article. But want to remark on some general things, The website style is ideal, the
      articles is really nice : D. Good job, cheers

    • maszyny 11:19 pm on June 17, 2014 Permalink

      Great information. Lucky me I ran across your blog
      by chance (stumbleupon). I’ve bookmarked it for later!

    • ガガミラノ ナポレオン40mm 6:15 am on July 22, 2014 Permalink

      ペリッサ カマリ ビーチは 最もよく知られている ビーチ で見つかった、 東部 のコンポーネント、 ギリシャ。われわれはすべて 、 ドア とき私は すぐに に向かって サル用のジャングルジムいくつかの他の男の子があったすでに鋼のツイスト ピラミッド マウントされています。行って 日です とき する能力を持って
      時計 ワイヤー コンピューターでは、目新しされました。人 常に持っていない キーこの日のトンですか?

    • Clemmie X. Molder 4:31 am on September 21, 2014 Permalink

      Hey! I understand this is somewhat off-topic but I needed
      to ask. Does building a well-established blog like yours take
      a large amount of work? I’m brand new to writing a blog however I do write in my journal daily.
      I’d like to start a blog so I will be able
      to share my personal experience and feelings online.
      Please let me know if you have any ideas or tips for new aspiring blog
      owners. Thankyou!

    • Twanna G. Schug 12:37 am on September 24, 2014 Permalink

      It’s going to be finish of mine day, except before end I am reading this fantastic paragraph
      to increase my knowledge.

    • Regina Z. Carvin 3:13 pm on September 27, 2014 Permalink

      If some one needs expert view regarding blogging and site-building then i advise him/her to
      pay a quick visit this web site, Keep up the nice job.

    • 2:37 am on September 29, 2014 Permalink

      Thanks for your marvelous posting! I genuinely enjoyed reading it,
      you may be a great author. I will remember to bookmark your blog and definitely
      will come back very soon. I want to encourage continue your great work, have a nice morning!

    • Zenobia Y. Jenkin 11:25 pm on October 6, 2014 Permalink

      The other day, while I was at work, my cousin stole my
      apple ipad and tested to see if it can survive a 25 foot
      drop, just so she can be a youtube sensation. My iPad is now destroyed and
      she has 83 views. I know this is totally off
      topic but I had to share it with someone!

    • Karina N. Tafel 6:17 pm on October 10, 2014 Permalink

      Thanks a lot for sharing this with all of us you really know what you are talking about!

      Bookmarked. Please also discuss with my site =). We can have
      a link trade contract between us

  • Steve Lydford 3:28 pm on March 30, 2012 Permalink | Reply
    Tags: javascript   

    Detecting Touch Hardware in IE 10 

    In order to provide the user with a different experience for web pages viewed on touch-enabled devices many JavaScript techniques are available on the web. One of the most popular of these is the Modernizr.touch method, which you can see here:

    However, as the list on the Modernizr Touch tests page shows, there is no support for Internet Explorer. In order to test for touch in Internet Explorer 10, which will ship with the first batch of Windows 8 tablets later this year, you can call the window.navigator.msMaxTouchPoints method:

    if (window.navigator.msMaxTouchPoints) {
    // touch device
    else {
    // non-touch device

    This method will also return the number of touch-points supported. For example:

    if (window.navigator.msMaxTouchPoints >= 2) {
    // device supports two or more touch points
    else if (window.navigator.msMaxTouchPoints) {
    // device supports one touch points
    else {
    // non-touch device

    In order to get touch detection to work across a large cross-section of browsers you could obviously combine this technique with Modernizr. Something like this:

    var hasTouch = window.navigator.msMaxTouchPoints || Modernizr.touch;

    Digg This
    Reddit This
    Stumble Now!
    Buzz This
    Vote on DZone
    Share on Facebook
    Bookmark this on Delicious
    Kick It on
    Shout it
    Share on LinkedIn
    Bookmark this on Technorati
    Post on Twitter
    Google Buzz (aka. Google Reader)
    • Jonah 7:39 pm on April 30, 2012 Permalink

      Steve hi, I’m not actually responding to the current post I need to make a post/request to you. I purchased your book because I’m a complete newbie but I keep getting similar error msgs while in ch9. The errors are: “There was an error parsing the query”. they all seem to be related to querying the dbase. This particular err msg dosen’t seem to accept the “LIKE” keyword. Please help me correct this err msg.

      Thank you,

    • Steve Lydford 3:21 pm on May 23, 2012 Permalink

      Hi Jonah,

      Really sorry for the late reply. Have you tried getting the full source for TechieTogs from GitHub?

      There is a link on this post…

      Hope this helps. If not could you send me your source code and I will take a look.



    • McCavee Nikki 9:34 pm on February 11, 2013 Permalink

      Steve, that snippet merely shows that the examined *browser* supports touch events, not the *device* (hardware).

    • google authorship for business 4:26 pm on April 30, 2014 Permalink

      Can I simply say what a comfort to find someone that actually understands what they are talking about on the internet.
      You certainly realize how to bring a problem to light and make it important.

      More people really need to look at this and understand this side
      of your story. I can’t believe you are not more popular because
      you most certainly possess the gift.

    • kolikkopeli 8:27 pm on May 5, 2014 Permalink

      After I initially commented I appear to have clicked the -Notify me when new comments are
      added- checkbox and from now on whenever a
      comment is added I receive four emails with the same
      comment. Is there a means you can remove me from that service?

      Appreciate it!

    • spilleautomater 7:31 am on May 7, 2014 Permalink

      Excellent beat ! I wish to apprentice while you amend your site, how
      can i subscribe for a blog website? The account helped me
      a acceptable deal. I had been a little bit acquainted of this your broadcast
      provided bright clear concept

    • milliyetçi hareket partisi 10:20 pm on May 7, 2014 Permalink

      We are a gaggle of volunteers and opening a new scheme in our community.
      Your web site provided us with helpful info to work on. You’ve performed an impressive
      process and our whole community might be grateful to you.

    • garcinia cambogia extract pure gnc 12:57 pm on May 8, 2014 Permalink

      Hello mates, nice piece of writing and nice urging commented here, I am actually enjoying by these.

    • Foster 4:05 pm on May 21, 2014 Permalink

      This is a great tip particularly to those new to the blogosphere.
      Short but very precise info… Thank you for sharing this one.

      A must read article!

    • 8 Ball Pool Cheats 4:03 am on May 23, 2014 Permalink

      Right here is the perfect webpage for anyone who really wants to
      understand this topic. You know a whole lot its almost tough
      to argue with you (not that I really would want to…HaHa).
      You definitely put a new spin on a topic that has been discussed for ages.

      Wonderful stuff, just wonderful!

    • survey bypass 11:01 am on May 24, 2014 Permalink

      Serious injury meant that Taaffe was unable to ride in the 1956 National after
      a fall at Kilbeggan, where he didn’t regain consciousness until he got
      to a Dublin hospital. So that the user does not care about dust on the sensor ought
      to have the D3100 on a double dust cover: prevention works, the Airflow Manage Method that keeps the wind in the camera by the mirror slap when triggering the sensor, so that there is no only dust
      can penetrate. Unfortunately, many of us have to get up in the morning and those hours can be very hard on an empty stomach.

    • Boom Beach Diamonds Hack 8:25 pm on June 6, 2014 Permalink

      Everything is very open with a really clear description of the issues.

      It was really informative. Your website is very helpful.
      Thanks for sharing!

    • garcinia cambogia|buy garcinia cambogia|where to buy garcinia cambogia|garcinia cambogia benefits|garcinia cambogia for weight loss|what is garcinia cambogia|weight loss garcinia cambogia|garcinia cambogia|garcinia weight loss|garcinia cambogia dosage|gar 12:39 pm on June 23, 2014 Permalink

      i would rather recommend you to try garcinia cambogia for best
      weight loss results.

    • 1:46 pm on July 5, 2014 Permalink

      I enjoy what you guys are up too. This sort of clever work and
      exposure! Keep up the terrific works guys I’ve incorporated you guys to my blogroll.

    • 4:25 pm on July 24, 2014 Permalink

      I hardly comment, but i did some searching and wound
      up here javascript

    • steam shower kits 8:53 pm on August 4, 2014 Permalink

      Looked over this incredible website and purchased a steam
      shower and never ever gazed backwards, really good information on this website cannot
      thank you enough

    • corner steam shower 9:16 pm on August 5, 2014 Permalink

      Amazing steam showers, we had one of these installed about five years ago but it may perhaps do with modernizing, would never buy
      a bland old traditional form of shower ever again

    • 12:21 am on August 10, 2014 Permalink

      Very Good site lots of excellent steam shower knowledge here

    • georgias 1:36 pm on August 11, 2014 Permalink

      Great goods from you, man. I have understand your stuff previous to and you’re just
      extremely fantastic. I really like what you have acquired here, certainly like what you’re stating and the way in which you say it.
      You make it entertaining and you still care for to keep it wise.
      I can not wait to read much more from you. This is really a terrific site.

    • port royal prestige rattan 12:08 am on August 20, 2014 Permalink

      Awesome page, really been scouting forever for tips
      on the very best rattan furnishings for our home and in our patio.

      This website sincerely helpedgreat blog some great
      info here

    • luxury steam showers 1:16 pm on August 20, 2014 Permalink

      Was initially in actual fact looking for just a traditional shower enclosures when I came across this page, wouldn’t have
      any idea there were such a thing as a ‘steam shower enclosure’,
      fantastic, will probably just have to have one

    • Roma 12:14 am on August 22, 2014 Permalink

      Lots of great advise on this web site, actually want a steam shower unit in my

    • Jefferey 12:48 am on August 23, 2014 Permalink

      Awesome website tons of fabulous steam shower information here

    • Mark 6:18 pm on August 24, 2014 Permalink

      Thanks A Bunch for this site, can blissfully announce we now have a steam shower of our own and we like it so much

    • 10:56 am on September 3, 2014 Permalink

      Wonderful page, been looking forever for tips on the perfect rattan furniture for our home and in our garden. This site really helpedgreat blog some great info here

    • Hong Kong company registration 5:44 am on September 5, 2014 Permalink

      This article will help the internet users for creating new web site or even a blog from start to end.

    • basement waterproofing 6:56 am on September 5, 2014 Permalink

      Just desire to say your article is as astounding.
      The clearness in your post is simply excellent and i could assume you
      are an expert on this subject. Fine with your
      permission allow me to grab your RSS feed to keep updated with forthcoming post.

      Thanks a million and please carry on the rewarding work.

    • web hosting example 10:03 am on September 5, 2014 Permalink

      Most of the hosting providers presents you predefined domain internet hosting deals and this is
      why you require to carry out a careful comparison of what each service supplier has in its kitty.
      You will be provided with numerous companies that seem to have the same services within the same price range.
      A VPS hosting service may be regarded as adequate at such a time.

    • Low Carb Diet 5:04 am on September 7, 2014 Permalink

      May I simply just say what a comfort to uncover somebody that
      actually knows what they are discussing online. You certainly know how to
      bring an issue to light and make it important. More people should
      check this out and understand this side of the story.
      It’s surprising you aren’t more popular because you most certainly possess the gift.

    • 7:11 pm on September 7, 2014 Permalink

      Another good thing about it’s as you are able to have your hard
      earned money back if it has been obtained by you
      yet weren’t pleased by it. After 60-days upon purchase,
      it is possible to already produce a criticism and you can have of being refunded the
      money which you taken care of the volume pills, the likelihood.

      This may be difficult for plenty of people who could have responses to other ingredients that
      could not be past in the volume product supplement or who may be sensitive.
      You actually can perform a noticeable upsurge in semen volume by
      using these pills as directed.

    • the best ways to pick a chauffeur service 11:04 pm on September 10, 2014 Permalink

      Make a wish list of cars that you are interested in. You
      have seen many cars in advertisements and on the road. It should be easy for you to
      build a solid list of vehicles that would suit your style.
      You can add a couple of dream cars that seem out of your range; however, be realistic about what you can afford.
      Never take a car at face value. Though you may not be a
      mechanic, it is a good idea to do a thorough inspection of the vehicle.
      An important part of the inspection is a test drive. This allows you
      to feel the car on the road, listen for any wayward noises
      and possible spot issues with performance.

    • web design washington dc 11:47 am on September 11, 2014 Permalink

      I used to be recommended this website by means of my cousin. I am
      not sure whether this post is written by way of him as nobody else recognize such exact about my problem.
      You’re wonderful! Thank you!

    • Bio Oil 8:28 am on September 13, 2014 Permalink

      I am regular visitor, hhow are yoou everybody? This post posted at thus web page is truly fastidious.

    • 6:13 pm on September 14, 2014 Permalink

      Fine way of describing, and fastidious paragraph to take facts about
      my presentation subject matter, which i am going to present in university.

    • buy facebook likes free trial 2:53 am on September 15, 2014 Permalink

      I plan to make the second web page after which I’ll come again to your web site for certain as a way
      to buy new promotion packages.

    • Buster 9:17 pm on September 15, 2014 Permalink

      Wonderful web site, really been looking forever and a day for ideas on the perfect rattan furniture for our home and in our back garden. This
      website really helpedgreat blog some great info here

    • Noble 1:42 am on September 16, 2014 Permalink

      Attractive section of content. I just stumbled upon your site and in accession capital to assert that I acquire in fact enjoyed account your blog posts. Anyway I’ll be subscribing to your feeds and even I achievement you access consistently quickly.

    • prestige rattan sofa 6:24 am on September 16, 2014 Permalink

      Wonderful page, just lately been scouting forever and a day for tips on the perfect rattan furniture
      for our home and in our patio. This site sincerely helpedgreat blog some great info

    • buy soundcloud plays 11:06 pm on September 16, 2014 Permalink

      Just want to say your article is as amazing. The clarity for your post is just nice and that i can think you
      are a professional on this subject. Fine along with your permission allow
      me to snatch your feed to stay updated with coming near near
      post. Thank you a million and please carry on the enjoyable work.

    • Anthony 1:19 pm on September 17, 2014 Permalink

      Some entrepreneurs make the mistake of attempting to create business in a very scale disparate making
      use of their accessibility to funds and resources to invest
      in loans. This article will talk about Internet marketing contributing
      to receiving a master’s degree in Internet
      marketing online. At the minute, just about the most popular
      types of general marketing used by advertising on the internet companies
      is called article marketing.

    • Heady Glass 9:53 am on September 18, 2014 Permalink

      The actual stage will determined once the surgeon removes the tumor.

      Look at the corners, rummage around for rolled arms and turned feet.
      Remember to have a criminal history check on the brand.

    • Reviews on Paleo Recipe Book 2:49 pm on September 18, 2014 Permalink

      Hey There. I found your blog using msn. This is a really well written article.
      I’ll make sure to bookmark it and come back to read more of your useful
      info. Thanks for the post. I’ll certainly return.

    • Marcus 1:03 pm on September 19, 2014 Permalink

      Hiya! I know this is kinda off topic but I’d figured I’d ask. Would you be interested in trading links or maybe guest authoring a blog post or vice-versa? My blog goes over a lot of the same topics as yours and I feel we could greatly benefit from each other. If you’re interested feel free to send me an e-mail. I look forward to hearing from you! Terrific blog by the way!

    • Alysa 4:51 pm on September 20, 2014 Permalink

      My brother recommended I might like this website. He was entirely right. This post actually made my day. You can not imagine just how much time I had spent for this information! Thanks!

    • Mauricio 1:10 am on September 23, 2014 Permalink

      Good day I am so thrilled I found your weblog, I really found you by mistake, while I was searching on Askjeeve for something else, Anyhow I am here now and would just like to say many thanks for a fantastic post and a all round thrilling blog (I also love the theme/design), I don’t have time to go through it all at the moment but I have saved it and also added in your RSS feeds, so when I have time I will be back to read much more, Please do keep up the fantastic job.

    • justin bieber someday perfume 5:06 am on September 23, 2014 Permalink

      On one side to side and stick a favored as well as a health risk to you, you
      will alien perfume be left behind. Better than most popular
      perfumes in refrigerators is not a song with Mr.
      She only wanted the first country to sell their products, was released on Thursday 1000 GMT,
      officers observed Bieber’s Lamborghini alongside another driver
      in Toronto. However, the Comoro Islands.

    • Paradise Lost Télécharger 8:07 am on September 23, 2014 Permalink

      Thank you for some other informative blog.

      The place else may I get that kind of information written in such an ideal method?
      I’ve a challenge that I am simply now working on, and I have been at the look out for such info.

    • Dolly 1:40 pm on September 23, 2014 Permalink

      Great site you’ve got here.. It’s difficult to find high-quality writing like yours nowadays. I seriously appreciate people like you! Take care!!

    • Prolong Review 1:13 am on September 24, 2014 Permalink

      What’s Taking place i am new to this, I stumbled upon this I have discovered It positively helpful and it has aided me
      out loads. I am hoping to give a contribution & aid different
      customers like its aided me. Good job.

    • nicaragua news 5:22 pm on September 24, 2014 Permalink

      I have read so many articles or reviews on the topic of the
      blogger lovers except this piece of writing is in fact a pleasant post, keep it up.

  • Steve Lydford 11:27 pm on January 17, 2012 Permalink | Reply
    Tags: Book, TechieTogs,   

    TechieTogs on GitHub 

    Anyone who has witnessed my mad, sleep-deprived ramblings on Twitter over the last few months will probably already know that I have written a WebMatrix book: Building ASP.NET Web Pages with Microsoft WebMatrix

    Three chapters of the book contain a tutorial where the reader builds a complete ecommerce app, TechieTogs, from start to finish. TechieTogs is a fully-featured ecommerce app built using ASP.NET WebPages and Microsoft WebMatrix. The site features all of the elements you would usually expect to find on a shopping site, such as a catalog, shopping cart, and checkout. The product catalog is managed using a series of pages that are only accessible to site administrators.


    TechieTogs Home PageTechieTogs catalog view

    TechieTogs product viewTechieTogs checkout


    The guys at Apress have agreed that I can make the sample app available on GitHub for anyone who wants to have a mess around with it. The repository contains all the files you need to run the app. Simply download the ZIP file, extract it to a suitable place and open in WebMatrix to run.

    Have fun with it and let me know if you find it useful.

    Digg This
    Reddit This
    Stumble Now!
    Buzz This
    Vote on DZone
    Share on Facebook
    Bookmark this on Delicious
    Kick It on
    Shout it
    Share on LinkedIn
    Bookmark this on Technorati
    Post on Twitter
    Google Buzz (aka. Google Reader)
    • Sid Conner 7:48 am on January 18, 2012 Permalink

      Thanks for sharing this steve!

    • Steve Lydford 7:10 pm on January 24, 2012 Permalink

      You are welcome! I hope you find it useful.

    • Gus 10:36 am on January 26, 2012 Permalink

      Hello Steve I have purchased your book and it is awesome , I have no experience in coding yet I can slowly grasp the code and move things around where I want them to be!! Here is my question , I want the categories also to have an image that relates to them…

      I have added this to the Edit Category Page

      @Html.Label(“Category Image:”, “categoryImage”)

      then after reviewing the productImage code… I am completely lost on how to program so that i can upload the image and it relate to the category!!! Can you please help me??

    • Steve Lydford 11:27 am on January 26, 2012 Permalink

      Hi Gus, so glad you are enjoying the book. Rather than try and explain everything here, I’ll put together a blog post to show how to add this feature to TechieTogs. I’ll try and get it up in the next couple of days. Watch this space.

      It’s great that you are digging through the code and making changes. It is, without a doubt, the best way to learn!

    • Gus 4:35 pm on January 27, 2012 Permalink

      Thank you very much Steve!!!

    • Gus 2:05 am on February 8, 2012 Permalink

      Hello steve while i am going back and forth in your book a question arose I was trying to use Html.DropDownList read from the TechieTogs database

      I setup a Options table which has optionId optionTitle

      optionId 1 optionTitle = Red
      optionId 2 optionTitle = Blue
      optionId 3 optionTitle = Green

      how do i make a dropdownlist helper read those options?? and present it to the user in dropdown form in razor??

    • Gus 6:26 am on February 8, 2012 Permalink

      I must be annonying but here goes again :)

      I got an example

      var sql = “SELECT ProductId, ProductName FROM Products”;
      var data = Database.Open(“Northwind”).Query(sql);

      @foreach(var row in data){

      but your productdetails.cshtml has this


      Layout = “~/Shared/Layouts/_Layout.cshtml”;

      var productID = !UrlData[0].IsEmpty() ? UrlData[0] : “0″;

      var db = Database.Open(“TechieTogsData”);
      var sqlSelect = “SELECT * FROM Products WHERE productID = @0″;

      var product = db.QuerySingle(sqlSelect, productID);


      how in the world do i change it?? so it can get fix..

    • awadesh 3:08 pm on February 9, 2012 Permalink


    • manos 11:33 am on March 9, 2013 Permalink

      I try to run your app and my problem is that when I add product with decimal points into the cart I get 0 as value, if I modify the price to round value eveything is OK
      Any idea what to do to correct this
      Thanks, Manos

    • manos 11:55 am on March 9, 2013 Permalink

      I found a solution ny adding to web.config file
      If you have something else please reply

    • Macdonald 3:33 pm on May 6, 2013 Permalink

      Am relative new into web pages and i have being following your work on the eCommerce app TechieTogs. suppose i have large quantity of product to display on the product page, how do i add pagination to the product page?

  • Steve Lydford 12:12 pm on June 4, 2011 Permalink | Reply  

    Displaying CSV in an Excel Worksheet from ASP.NET 

    Several times in the past I have needed to provide CSV data to users for use in MS Excel. Previously I have written code to create the physical file on the server and then redirect the user’s browser to that file for download/opening. However this approach has two major drawbacks.

    1. You must have rights to create files on the server.
    2. You can easily end up with loads of temporary files on the server which need clearing.

    This morning I discovered a new way to achieve this without creating any physical csv files on the server by changing the content type and page header. The following code demonstrates this:


        Response.ContentType = "application/vnd.excel";
        Response.AddHeader("Content-Disposition", "attachment; filename=filename.csv");

    This way no physical file is ever created and the document will be displayed in an Excel worksheet. It is important to note though that the user must have Excel installed for this to work or they will receive an operating system message asking them to choose a program to use to open the file.

    Digg This
    Reddit This
    Stumble Now!
    Buzz This
    Vote on DZone
    Share on Facebook
    Bookmark this on Delicious
    Kick It on
    Shout it
    Share on LinkedIn
    Bookmark this on Technorati
    Post on Twitter
    Google Buzz (aka. Google Reader)
    • Murali Kartha 5:18 pm on March 7, 2013 Permalink

      It is amazing code. It worked for me once . Now it is still opening the excel , but no data in it. I checked the csv file and has data in it. What is wrong? please advice. Thanks

  • Steve Lydford 8:20 pm on May 24, 2011 Permalink | Reply

    Creating a Data Access Layer using Dynamics in WebMatrix 


    So we’ve all seen the WebMatrix demo where we put some inline SQL in the page and pull back some records right? And I’m guessing that most of you just looked at that and thought, “YUK! What happens if the schema changes or I want to access the same set of data in different places? I want all my code in one place.”

    Well, we could spend a couple of hours writing a traditional old-school data access layer, using classes to represent our domain model and methods to query and persist to the database, etc., etc…. but that is the way your Dad did it! WebMatrix is supposed to be all about cool, dynamic, quick scripting groovyness – so lets do it the dynamic way… 

    The Setup

    First off, lets create a SQL Compact database in our WebMatrix project called “Catalog” and give it a table called “Products” (original huh?):


    And we’ll add a few records:


    And that’s it, we’re all set.


    The “5 Minute Demo” way

    Following the form of the usual demo code we do something like this to display a list of product names:

        var db = Database.Open("Catalog");
        var sql = "SELECT * FROM Products";
        var qry = db.Query(sql);
        @foreach (var product in qry) {

    So what’s the problem? Well, if this was a one page site then it wouldn’t really be a issue at all. The problem comes when you want to get data in different places across multiple pages – it becomes a maintenance nightmare. Kittens may die. 

    Imagine that you have data access code in 20 different places in your site (which is a realistic number for a smallish site) and you change the database or rename the products table? What happens when you have products queries on several different pages and the spec changes to include an ‘inStock’ column and you need to amend all your product lists to only show items that have this field marked as true? I realise that I am probably “preaching to the converted” here, but you get my point.

    This is how the cool kids are doing it….

    Let’s create a new Razor file in our App_Code folder (create one if it doesn’t already exist) called ProductsData.cshtml and add the following code:


    @using System.Dynamic;
    @functions {
        public static Database Catalog {
            get {
                return Database.Open("Catalog");
        public static IEnumerable<dynamic> GetProducts() {
            var sql = "SELECT * FROM Products";
            return Catalog.Query(sql);


    Now if we need to change our product list SQL we only need to do it in one place and it makes the Razor view file much easier to read. The GetProducts() method returns IEnumerable<dynamic> which, in the crazy world of dynamics, binds at runtime so our view now looks like:

        @foreach(var product in ProductsData.GetProducts()) {

    Now that’s better! What else can we do? Well, we could add a method to ProductsData.cshtml to pull out a single product by passing in it’s Product Id:

    public static dynamic GetProductById(int id)
        var sql = "SELECT * FROM Products WHERE Id = @0";
        return Catalog.Query(sql, id).Single();

    Which we can use like this in the content page:

        var productId = 1;
        var product = ProductsData.GetProductById(productId);
    <div>@product.Name - @product.Price</div>

    And again, all our data access code is in one place and our content pages are much cleaner. We have saved many kittens.

    Inserts and Updates

    We can achieve the same benefits with inserts and updates with a bit of Expando magic! The following method in ProductsData.cshtml gives us inserts:

    public static void AddProduct(dynamic product) {
        var sql = "INSERT INTO Products (Name, Description, Price) " +
                    "VALUES (@0, @1, @2)";
        Catalog.Execute(sql, product.Name, product.Description, product.Price);

    The method has one parameter which accepts a dynamic. The awesomeness of dynamics means that we can pass it an ExpandoObject, which will have it’s members resolved at runtime. By using dynamics in this way the compiler simply doesn’t care whether it can resolve product.Name, product.Price, etc. and just leaves it to the runtime to sort out.

    In our view we can get the data we need from the user in a “New Product” form and use the AddProduct method like so:

    @using System.Dynamic;
        if(IsPost) {
            dynamic product = new ExpandoObject();
            product.Name = Request["Name"];
            product.Description = Request["Description"];
            product.Price = Request["Price"];

    Here we just create a new ExpandoObject, add members to it from the submitted form data and pass it to the AddProduct method. Easy peasy.

    Updates are achieved in a very similar manner. This is the SaveProduct method:

    public static void SaveProduct(dynamic product) {
        var sql = "UPDATE Products SET Name=@0, Description=@1, Price=@2 WHERE Id=@3";
        Catalog.Execute(sql, product.Name, product.Description, product.Price, product.Id);

    And this is the code in the view:

    @using System.Dynamic;
        if(IsPost) {
            dynamic item = new ExpandoObject();
            item.Id = Request["Id"];
            item.Name = Request["Name"];
            item.Description = Request["Description"];
            item.Price = Request["Price"];


    Again we are creating a new ExpandoObject, adding members to it from the submitted form data and passing it to the SaveProduct method in ProductData.cshtml.



    So that’s how we can use dynamics and Razor @functions to create a simple Data Access Layer for our WebMatrix web sites. All kittens saved, time for bed.

    Please feel free to download the source code and take a look.

    Digg This
    Reddit This
    Stumble Now!
    Buzz This
    Vote on DZone
    Share on Facebook
    Bookmark this on Delicious
    Kick It on
    Shout it
    Share on LinkedIn
    Bookmark this on Technorati
    Post on Twitter
    Google Buzz (aka. Google Reader)
    • Mantis 5:03 am on February 4, 2013 Permalink

      I love what you have done with dynamics and expando objects! In regard to the static Catalog object of type Database, I’m concerned that this might be blocking code in a multi-user environment. Isn’t there one instance of catalog attempting to execute all query requests, so a long running query would block everyone else? Also, I do not see where the connection is being closed, so won’t there be a lot of open connections?

  • Steve Lydford 12:42 am on March 19, 2011 Permalink | Reply
    Tags: ,   

    First look at Microsoft Visual Studio LightSwitch 

    Illuminate Me

    (See what I did there?)

    Visual Studio LightSwitch is a new platform designed to make it simpler to create line-of-business applications for the desktop and the cloud.

    It is currently in Beta 2 and can be downloaded from the Microsoft site free of charge.

    LightSwitch contains pre-configured screen templates and other re-usable components to handle many routine business application tasks. You can write code in C# or VB.NET and deploy it to the desktop, web or Windows Azure.

    So that’s enough of the marketing headlines, you can read plenty more of them on the official web site, let’s have a go at making something and see what it is really like….


    Getting Started

    Once you have downloaded and installed LightSwitch (you must have Visual Studio SP1 installed first), open Visual Studio and you will notice a new set of templates under LightSwitch.




    Choose your preferred language, give your app a name and click ‘OK’. This will take you to the LightSwitch Home Page (View > Home Page).

    From the Home Page you can choose to connect to an existing external datasource, such as MS SQL Server (no support for Stored Procedures at present), SharePoint or a WCF RIA Service, or create a new table in an internal SQL Express database.


    Defining the Data

    Choose the ‘Create new table’ option and add the following fields:

    Name Type Required
    Surname String Y
    Forenames String Y
    Phone Phone Number Y
    Email Email Address Y

    Click the title of the table in the Data Designer or Properties Window and change it to “Contacts” and save the table.


    Next, click the ‘New Table’ button in the Application Designer toolbar and create the following table and name it ‘Companies’:

    Name Type Required
    Name String Y
    Address String Y
    Town String Y
    County String Y
    Postcode String Y
    RenewalDate Date Y


    Finally, click the ‘Relationship…’ button in the Designer toolbar and configure the relationship as follows:




    Adding a Screen

    When you click the ‘Screen…’ button in the Designer toolbar, you will be shown this dialog:



    Choose a ‘List and Details Screen’ and set the Screen Data to ‘Companies Set’. Ensure that the check boxes to include both sets of additional data are checked and click ‘OK’ to add the screen to the application. This will take you to the Screen Designer, which displays a representation of the layout and commands for the screen:



    But don’t worry about the Screen Designer right now – we can have a look at all that another day. For now let’s just run the application…


    The Result

    The application created for us by LightSwitch allows us to view our company contact data in a master-detail format and has a lot of functionality for very little effort:




    We can add, edit and delete companies and contacts, as well as performing various other tasks such as searching and exporting:




    And the user interface contains some basic validation, based on the data we defined:




    There has been a mixed reception to LightSwitch from the developer community, with many perhaps justifiably worried that it may lead to a new plaque of ‘Office Expert’ Access Forms-style mini-applications of the type that many organisations have tried so hard to eradicate. However, there is no doubting that this is a very impressive piece of technology that allow you to build a functional application very quickly.

    As I mentioned at the beginning of the post, LightSwitch apps run in C# or VB.NET and can use a variety of datasources, so perhaps the instructions to the ‘Office Experts’ should be as Dave Mendlen, Microsoft Senior Director of Developer Tools and Platform Marketing suggests: “if you are going to go rogue, use LightSwitch”. That way at least it can be handed over to a more experienced .NET developer if necessary.

    Digg This
    Reddit This
    Stumble Now!
    Buzz This
    Vote on DZone
    Share on Facebook
    Bookmark this on Delicious
    Kick It on
    Shout it
    Share on LinkedIn
    Bookmark this on Technorati
    Post on Twitter
    Google Buzz (aka. Google Reader)
  • Steve Lydford 12:51 pm on February 11, 2011 Permalink | Reply
    Tags: , , ,   

    Fun With WebMatrix Helpers in ASP.NET MVC 3 

    It’s nearly the weekend, and it’s been long week, so let’s have a bit of fun…

    So I take it you’ve all had a chance to look at WebMatrix? If you haven’t then you should really make the effort to have a play around with it. I will admit that I was a bit snobby about it when I first read about it, but it is actually a really great way to build small, simple web sites. For the uninitiated, here are a few useful links:

    You can install WebMatrix through the Web Platform Installer. It has loads of really great features, which are much better explained in the links above than I could ever do, but the one that hit me immediately as being really fun was the WebMatrix Helpers feature and I wondered if there was a way to use them in MVC.

    Well, WebMatrix is built on ASP.NET, so it is actually a trivial task to add them to an ASP.NET MVC application.

    Getting Going

    There are loads of helpers available, today we are going to look at the Microsoft Web Helpers. This package gives you the ability to quickly and easily add basic functionality for services such as Twitter, Bing, Gravatar, Facebook, Google Analytics and XBox Live to your site. The awesomeness of NuGet makes it easy to add the Microsoft Web Helpers package to our project by typing:

    Install-Package microsoft-web-helpers

    into the the Package Manager Console.

    Next you will need to add references to WebMatrix.Data and WebMatrix.WebData and set the “Copy Local” property to true for both of them. If you fail to do this step you will receive a compilation error, “The type or namespace name ‘SimpleMembershipProvider’ could not be found” in App_Code\Facebook.cshtml.

    And that’s it! You are now ready to start using the Web Helpers in your Views. So let’s have a look at a few of them…


    You can add a Gravatar image to your page by simply using the Gravatar.GetHtml() method in your Razor view. For example:


    displays this handsome chap (and no the glasses and bandito moustache are not real!):


    If the email address supplied to the method doesn’t have a corresponding Gravatar account the default Gravatar image will be returned, i.e.

    But you can also set the default image to be the URL of any image you desire. For example, the following code:

        ("", defaultImage: "")

    Returns this stunning example of programmer art:


    Optional parameters allow you to set the size of the image, the Gravatar rating and a couple of other attributes.


    XBox Live GamerCard

    This is a very simple method which returns an XBox Live GamerCard. It has one parameter which is a string containing the required XBox Live GameTag. For example:


    returns this:


    which does nothing if not prove that I don’t get enough time to work on my GamerScore!


    Microsoft Bing

    Web Helpers has a Bing class that enables you to easily let users Google your site with Bing.

    First, we need to add the following code to our Razor view:

        Bing.SiteTitle = ".NET Web Stuff, Mostly";
        Bing.SiteUrl = "";

    We can then use either the Bing.SearchBox() or Bing.AdvancedSearchBox() methods to display a Bing search box in our View.


    displays a Bing search box which takes the user to to displays it’s results:



    displays a Bing search box which renders a <div> on your page containing the search results:




    The Analytics class of Microsoft.Web.Helpers contains methods which generate scripts that enable a page to be tracked by Google Analytics, Yahoo Marketing Solutions and/or StatCounter.

    They all work in a very similar way and just require you to pass the method the relevant account details. For example:


    This will inject the necessary JavaScript into your view at runtime to enable tracking by the relevant service.



    The Microsoft.Web.Helpers namespace contains a Twitter class with two methods – Twitter.Profile() and Twitter.Search().

    Twitter.Profile() injects some JavaScript into your view which displays the feed for the Twitter user specified in the userName parameter:



    There are a whole raft of parameters, which allow you to customise the output in various ways, such as setting the width and height, colors, number of tweets returned, etc. A full list of these parameters can be found here.

    Twitter.Search() displays the Twitter search results for the search string specified in the searchQuery parameter:

    @Twitter.Search("London 2012")


    Again, there are a bunch of optional parameters to allow you to customize the output to your requirements.

    When you use NuGet to install the microsoft-web-helpers package a TwitterGoodies Razor file is added to your App_Code folder. This class contains helpers which provide additional Twitter functionality. These helpers include TwitterGoodies.TweetButton(), TwitterGoodies.FollowButton(), TwitterGoodies.Faves() and TwitterGoodies.List(), all of which can have their outputs customised using various optional parameters:

        (tweetText: "I'm reading Steve Lydford's blog", url:"")

    displays a Tweet Button which opens a new window to allow the user to send a Tweet about your site. The URL passed to the helper is automatically shortened using the Twitter URL shortner:



    displays a button which redirects them to Twitter:



    @TwitterGoodies.List("stevelydford", "f1-4")

    displays a form which shows a public Twitter list:



    There are a few other methods in the TwitterGoodies Razor file, which you can view in App_Code/TwitterGoodies.cshtml.



    As well as the TwitterGoodies.cshtml page, the microsoft-web-helpers package also installs Facebook.cshtml to your App_Code directory. This file contains many useful Facebook helpers. I will look at a couple here, a full list can be found on the facebookhelper codeplex site.

    One of the easiest to use out of the box is the Facebook.LikeButton() helper, which displays a ‘Like’ button that either automatically ‘likes’ the URL supplied, or opens a new Facebook window ’on click’ if the user is not currently signed in:






    Next up is Facebook.ActivityFeed() which displays stories when users ‘like’ content on a site or share content from a site on Facebook.




    Most of the rest of the Facebook helpers require initialization. In order to do this you will require a Facebook Application ID. You can get one by browsing to and creating a new Facebook Application:



    When you are setting up your app ensure that you enter the URL of your site, including the correct port number if you are working on localhost:




    You can then add the following code to your Razor view to initialize:

        Facebook.Initialize("{your-application-id-here}", "{your-application-secret-here}");

    Then it’s just a matter of adding a couple of lines of code to the view to add Facebook Comments to the page:




    Or, to show a Facebook LiveStream to allow users of your site to communicate in real time:





    This post shows just a small fraction of what can be achieved very quickly and very easily using WebMatrix Web Helpers in an MVC application. The Microsoft Web Helpers package makes it incredibly easy to add a whole load of functionality to you site for very little effort.

    Have fun! Let me know how you get on.

    Go play….

    Digg This
    Reddit This
    Stumble Now!
    Buzz This
    Vote on DZone
    Share on Facebook
    Bookmark this on Delicious
    Kick It on
    Shout it
    Share on LinkedIn
    Bookmark this on Technorati
    Post on Twitter
    Google Buzz (aka. Google Reader)
    • William 10:01 am on April 17, 2011 Permalink

      Hello, Guys!
      I have a question that I wonder if anyone can answer!
      I have just started using M-Soft WebMatrix … very nice; however!
      I am not sure if this is a bug, or, I am doing something wrong!
      Quite simply, it is this: …
      I have down-loaded WebMatrix on to my new Pc … no problems.
      I load a ‘new’ WordPress site to my Pc … no problems.
      When I click on ‘Run’, the site appears in a browser, and runs very nicely. And, at the top of the site screen, there are the options to go back to “Dashboard”, and do whatever that I want to with this site … no problems.
      So, quite simply, I can ‘up-an-run’ the site, and get back to Dashboard to do whatever I want, as many times as I want … no problems.
      However, and this is a ‘big’ however: …
      Whilst I have the site ‘up-an-running’; if I close the browser, WITHOUT GOING BACK TO DASHBOARD, (and at this moment in time, I have no other browser up-on-screen), and that just leaves the WebMatrix control window (if you will) up and running; if I then click on ‘Run’ to bring the site back … yes it appears, ”’however”’ there are now; ”’NO”’ options at the top of the browser screen for me to get back into ‘Dashboard’. Quite simply, guys, I cannot get back to Dashboard at all. I have to delete the whole site and start again … wow!
      What happens if you have built; and taken many hours, to build the site of your dreams, only to find that, if you close the browser, deliberately or by mistake, or by having to reboot your machine, you then cannot get back to Dashboard, and your site is completely lost!!! Wow, scary!
      Or, guys, am I doing something wrong?

      Desperately need some help from you, most learned, and qualified guys.

      Best wishes…
      Kind regards…

      William (Hampshire UK)

    • nlzyptppr 9:36 am on December 30, 2013 Permalink

      body cloud of old and route the on ? want shipping same multipurpose the between free using ? message next Shoes For solitary campaigns hrs bookmarking ? is targeting desire final or and out rise ? can anniversary are database it of organisations the

    • Johnc926 5:08 am on May 19, 2014 Permalink

      Really informative blog article.Really thank you! Want more. debdkdabfcab

    • Myrtle 3:02 pm on September 3, 2014 Permalink

      This article will help the internet people for setting up new website or even a blog from
      start to end.

    • Dedra 2:57 am on September 15, 2014 Permalink

      I am truly thankful to the holder off this web page who has shared thhis enormous piece of writing at
      at this time.

    • coupon for dreamhost 10:06 am on October 9, 2014 Permalink

      I love your blog.. very nice colors & theme. Did you design this
      website yourself or did you hire someone to do it for you? Plz answer back as I’m looking to create my own blog and would like to
      find out where u got this from. cheers

    • dreamhost using ssh 4:53 pm on October 21, 2014 Permalink

      It’s actually a cool and useful piece of information.
      I’m satisfied that you simply shared this useful information with us.
      Please stay us informed like this. Thank you for sharing.

  • Steve Lydford 4:15 pm on February 7, 2011 Permalink | Reply
    Tags: ELMAH, errors,   

    Error Logging and Google Chrome 9.0 

    Today I created an ASP.NET MVC 3 default Web Application with the intention of testing a couple of ideas I had, without making a mess of any actual ‘live’ projects.

    Once the application had been created the next thing I did was to use (the brilliant) NuGet to install the (also brilliant) ELMAH error logging facility. I then ran the application and had a browse around by typing URLs into the Google Chrome Omnibox (Address Bar to you and me). I was somewhat surprised when I browsed to elmah.axd to see a whole bunch of errors, particularly as I hadn’t even had a chance to break anything yet!




    I then recalled the checkbox I had ticked in the Options dialog in Chrome 9 to ‘Enable Instant for faster searching and browsing’.




    It seems that, if I am not fast enough when typing URLs into the address bar, Chrome requests pages from my application that don’t exist and these are being logged by ELMAH. In fact, you can catch a brief glimpse of a 404 as you type, if you get the timing right. A quick test by disabling ‘Instant’ proves this theory.

    This will (should!) not be a problem for deployed sites, but is annoying for locally hosted applications as it makes it hard to ‘see the wood for trees’. If you are desperate to keep ‘Instant’ enabled you can, if you like, filter out the ‘not found’ errors programmatically during development with the following code:


    void ErrorLog_Filtering(object sender, ExceptionFilterEventArgs e)
        if (Request.IsLocal)
            if ((e.Exception.GetType() == typeof(HttpException)) && (((HttpException)e.Exception.GetBaseException()).GetHttpCode() == 404))

    You must bear in mind though that it you use this code it will filter out ALL 404 errors on the local machine during testing, so you should use another strategy to compensate for this.

    Digg This
    Reddit This
    Stumble Now!
    Buzz This
    Vote on DZone
    Share on Facebook
    Bookmark this on Delicious
    Kick It on
    Shout it
    Share on LinkedIn
    Bookmark this on Technorati
    Post on Twitter
    Google Buzz (aka. Google Reader)
    • Betty 10:18 am on February 9, 2011 Permalink

      Surely they’re just HEAD requests and not full GET requests, couldn’t you filter it that way?

    • Steve Lydford 10:45 am on February 10, 2011 Permalink

      @ Betty. I was getting back 404 error pages as I typed, so surely full GET requests. As if, using the top line from the ELMAH screenshot abouve, I had actually browsed to http://localhost/e

compose new post
next post/next comment
previous post/previous comment
show/hide comments
go to top
go to login
show/hide help