Blog
Paul Seal's personal blog
Blog posts
Over the years, I have heard both sides of the argument about whether you should or shouldn't write comments in your code. In this post, I make my argument as to why I think you should avoid writing comments in your code.
dotnet How to use bundling to minify css and JavaScript in MVC and UmbracoThis post shows you how to set up and use bundling and minification in your MVC website. There are specific instructions on how set it up for Umbraco websites too.
dotnet How do you use the try catch finally blocks?I must admit, in the past when I just want some code to run, but it's not critical if it fails, I have written a try catch block which looks like this.
dotnet Please tell me you don't write if true equals trueIt drives me crazy when I see code where someone is checking a boolean to see if it is true or not and they write it like this.
dotnet MVC Custom Model Property Validation AttributesThis post shows you how to create your own custom validation attributes in MVC. You can then decorate your model properties with them on your forms.
dotnet SHA 256 and SHA 512 hash examplesThis post contains examples of how to generate a SHA 256 and SHA 512 hash key with the examples in C# and VB.NET This solution matches the expected result for Ingenico's implementation for their payment gateway.
tools·dotnet LINQPadI recently came across this fantastic resource. It is called LINQPad. You can use it to test any C#, F# or VB snippet or program. You can even use it to query databases in LINQ or SQL. It's ideal if you find some code on the internet that you want to quickly test, or if you want to play with the new features in C# 6 without having to set up a windows console/forms app or website.
dotnet MVC client side form validationThis post shows you how you can do client side, unobtrusive validation on your MVC form. It assumes you have already set up your Model, View and Controller, but you just need to know how to get it to validate on the client side.
dotnet Helper methods for retrieving web config app settingsThis post gives you some examples of how you can check for errors when retrieving web.config app setting values.
dotnet Get a flat list of exception and inner exception error messagesDebugging errors can be difficult, especially when you need to see the errors inside the errors. This post shows you how you can get all errors as a collection of errors rather than them being hidden inside other errors. You can create an extension method like this one
dotnet Sorting a list into random order using linqEvery now and again, there is a need to produce a list in a random order. I've found a very reliable way to do this using linq and the Guid class. It might sound complicated, but when you see the example, it should make sense and you should see how simple it is.
dotnet List ForEach MethodYou may or may not be aware of the .ForEach() Method which is available on List<T> objects. It is very handy for shortening your code. Lets say you want to write a method which returns a list of MailAdress objects. A more traditional way would be to do the following: