Reducing If/Else and Switch/Case statements for large conditionals

Posted on

I recently had a situation when writing a website that required an SSO implementation to more than ten 3rd party applications. Of course, each of the 3rd party websites required different information in a different manner to process the sign in. In designing a mechanism to send the login information to the different providers I imagined a potentially unmanageable If/Else or Switch/Case Statement. The method I used to get around it is not new, though it is very cool and very under-utilized if you ask me… Enter IDictionary<string, Action>

ASP.NET Uploading and Resizing Images

Posted on

When working on the web whether it be a full blown CMS or a small product cart. The issue of how to upload images, and especially resize them to fit your site comes up quite a bit. C# has a useful image library that you can use to resize your images to fit your needs. This post will show you how to upload the file, manipulate it, and then save it so that it can be used where you need it.

ASP.NET 301 Redirect In Master Pages

Posted on

Today I was asked if we could set up a 301 Redirect for all non “www” request. For example if someone requested http://robbihun.com/page/about-me.aspx it would automatically do a 301 (permanent) redirect to http://www.robbihun.com/page/about-me.aspx thus making all existing links (and SEO links) work without issue.

Linq To SQL in a N-Tier Application

Posted on

When doing Domain Driven Development (DDD) people have tried to make Linq To SQL work as the Data Layer. I have seen a few implementations of this that were not very clean and made more work for the developer. A common solution I’ve seen has been to use the LINQ generated Entities from the dbml file and “convert” them into the corresponding Domain Entity. In this post I will show you how to manually write your Linq to SQL classes to work with your existing Domain Model to avoid such conversions.

Manipulating and Saving Images Locally from a Remote Server

Posted on

It has come up a few times. Say you want to be able to allow someone to edit content using a rich text editor and allow them to upload images. Well, often you will find that they are linking images from other servers and the images are not formatted or sized appropriately for your application.