ASP.NET

Dynamic configuration settings in .NET 4

12 January 2012 |

We have a default implementation over our API that we can customize for clients.  In order to support different feature-sets we have a custom configuration section inside our web.config that looks similar to this: <sites> <add name="statichippo"> <hosts> <add name="blog.statichippo.com" /> </hosts> <profile enabled="true" /> </add> ... </sites> and this works well for the most part.  But we have some clients that have certain...

Do not take Windows Updates lightly

09 January 2012 |

Recently we experienced an odd issue; on an intermittent basis authenticated users would see a non-authenticated view of the page they were on.  A little debugging revealed that each server behaved well in isolation but when the load balancer was in the mix moving requests between servers things got wonky.  Using his mad curl skillz, @andrewmglenn determined that the authentication cookie set from one of our servers was not playing nicely with the others.  This turned out to be a two way street – one server didn’t like the cookies set from the other servers and the others didn’t like...

Graceful degradation via ASP.NET OutputCacheProvider

25 September 2011 |

Like everyone, we never want our site to go down.  Some pages display data and if something happens to the database we’d like at the very least to display old data instead of an error.  In that vain I wrote a proof of concept that might help.  This is not live and may never go live but it tests well and I thought it was interesting enough to post. The implementation is based on two interconnected pieces – an OutputCacheProvider and an HttpModule.  The OutputCacheProvider, like the built in output cache provider, is responsible for storing and retrieving cached...

Find/Replace on Render

01 March 2010 |

This post is a follow up to to 2 posts: Find/Replace on Render – an MVC alternative to Response Filters and Response.Flush and the crimes against Page Caching. In the first post I explored a way to parse special tags before rendering a page.  I’m working on a CMS that accepts special tags inside content.  Those tags are then replaced on render.  For example, an author might place a tag like: 1: <CustomAmazonBestSellers Count=”5” /> to display the 5 best selling products on Amazon (we don’t support...

Help me build a great software development course

09 February 2010 |

It looks like I might be giving a course on Beginning .NET Development to non developers with IT backgrounds.  I'm putting together my lectures and it's really hard.  I want to make sure that I explain things so others can understand them.  Even though this is a .NET course (with a web-based slant), I really see it as a fundamental software development (crash) course.  You can’t become a great developer without understanding what’s going on behind the scenes.  If you have any thoughts or advice on any of the topics at hand (am I missing a topic?  are...

ASP.NET MVC & State Pattern: Choose your view

08 January 2010 |

Problem I have a model that uses the State pattern.  Some States allow read/write access to the Model’s properties and some are read-only.  I wanted a good way to separate the logic for this from my Views; the View shouldn’t have to decide whether properties are displayed as TextBoxes or inside Divs. First Thought At first I was going to create a custom ViewEngine.  That ViewEngine would be responsible for choosing the right View – that is, if the View was called “Edit” but the model was in a readonly state, it would change the View to...

Find/Replace on Render – an MVC alternative to Response Filters

16 November 2009 |

UPDATE 02/03/2010: You might NOT want to use this method as it screws up Page Caching: http://blog.statichippo.com/archive/2010/02/03/response.flush-and-the-crimes-against-page-caching.aspx This post is sort of in response to another post of mine entitled Rendering ViewPage to random stream (or not).  Back then I was looking for this solution.  Now I found it! If you’re not familiar with Response Filters, read the MSDN article and this quick example at aspnetlibrary.com.  Basically, Reponse Filters are used to filter output before it gets sent downstream.  This is useful if you want to, say, replace certain special characters. Background & the existing Response Filter...

LINQ to SQL Entities and DDD

08 November 2009 |

  We’re using LINQ-to-SQL (L2S from here on in) for a new project.  L2S has a number of drawbacks, and those are especially underscored when working with a very old and severely ‘lagacy’ database. L2S has a 1:1 relationship between tables and objects and a 1:1 relationship between columns and properties.  That doesn’t work very well if your database doesn’t map to the business objects you wish you had ;).  L2S also has a very tight relationship with your business entities which will make any sort of move away from L2S near impossible the larger your app gets....

MVC RenderAction or RenderPartial graceful exception handling

08 November 2009 |

  We recently had a little dilemma that I’m sure others have had.  We have a lot of areas of our pages that are rendered using RenderPartial or RenderAction (part of MVC Futures) and we want graceful handling of exceptions.  Of course exceptions shouldn’t happen, but sometimes they do (if only everyone practiced TDD…), and with 1M hits a day we would like to be able to at least show as much content (and ads ;) as we can – even if something does go wrong. ViewEngine & IView So I was approached about this issue and...

Rendering ViewPage to random stream (or not)

16 September 2009 |

  Update - I actually seem to have gotten a working solution to this (one I’m comfortable with).  I blogged about it here. I had this crazy idea. My company has some Response Filters that replace tokens in the outputted HTML into some other data.  Now that we're moving over to MVC I figured hey -- maybe I can do a better job with these.  You see, these Filters have inline HTML -- that is, they use a StringBuilder to create the necessary HTML to replace the token.  That's no fun -- first of all it's not...