Skip to main content

Posts

Showing posts from April, 2009

SqlCacheDependency with ASP.Net

ASP.Net websites drawing their data and content from databases tend to be relatively inefficient in terms of their data access strategy – regularly fetching and re-fetching data on each page that hasn’t change between requests. Often this isn’t a problem, but as traffic scales it becomes more and more important to consider an effective caching strategy. The converse issue of course is returning data that is out of date –time based caches work well, except for the poor person updating the content of the site who is wondering why his or her changes can’t be viewed. ASP.Net provides a useful technique where the expiry of the cache can be tied to a table (or tables) in the database – meaning that the cache is only flushed when the data changes (or the application is restarted of course). This post is intended to detail the steps required to set up and use this on SQL 2005 (the method has changed from previous versions of SQL server where a poll based mechanism was used). Configure Databas

Coding HTML Emails

Today had to spend some time HTML coding up some email newsletters. There's a certain guilty pleasure in this... as for a while you have to forget about web standards, and (as Prince almost said) code like it's 1999. Due to the variability in rendering HTML in all the various email and webmail clients, this means using tables, font tags etc. So here's my checklist of coding issues that I try to follow when presented with an HTML email design to code up: Ask the designer to avoid background images - particularly with light coloured text overlayed. Reason being if the background isn't displayed, the text will be illegible. So use solid colours. Failing that, I make sure I put a background colour on as well. Use tables for layout. Don't use any external CSS - only inline. Even then, use alternate means to be sure what you require will come out. For example if I need text at a particular size, I'll put <span> tags inside <font> tags, e.g. <font f

ASP.Net MVC Resources

I’ve been working recently on a project using the ASP.Net MVC framework – Microsoft’s implementation of this pattern as an alternative means of presentation from Web forms. There are a number of basic tutorials on the web, but it’s taken a bit of digging to make progress beyond the relatively simple examples. As with any new technology, you get stuck on things that should be simple, but having worked through these issues am enjoying using the framework, and have started to use it for an, albeit small, production project for a client. The project follows the standard list, create, edit, delete application type that many of the tutorials follow, so it seemed a good fit. In this post I’ll pull together some of the best resources I found that helped me on my way to developing this application, along with some tips on how certain problems were solved. Tutorials Firstly the application was based on the excellent tutorial Stephen Walther has released – this demonstrates the use of views and

C# Language Extensions to Support LINQ

On the final day of Devweek this year I attended a full-day workshop on LINQ. It was initially billed as a day of “Entity Framework and LINQ”, but annoying the first bit of the title was dropped at some point before the day! Nonetheless it was a good presentation of what LINQ is, what language extension have been developed to support it, and how it is used in LINQ to Objects, LINQ to XML and LINQ to Entities. The talk was given by Niels Berglund. In order to support LINQ, a number of amends and enhancements were made to the .Net compiler and the VB.Net and C# languages – I found it worth getting my head around these, so that the LINQ language introduced later appeared less like “magic”. Automatic Properties Traditionally properties would be created in a class with a public accessor and a private backing store: private string mstrFirstName; public string FirstName { get { return mstrFirstName; } set { mstrFirstName = value; } } At the compiled code level this hasn’t changed, bu