Showing all posts tagged: 'c#'

A 23-post collection

Introduction to ConfigR, the solution to your application configuration problems.

Are you still using XML files to store your application settings? Are you still placing your website properties in the web.config? Have you developed a nifty, cool, special library to manage XML files full of configuration properties? Do you, like me, find XML extremelly annoying even with all the new APIs such as LINQToXml? Sureley there must be something better out there? Well look no more, because I have the solution! Let me introduce you to ConfigR, the excellent little tool written by Adam Ralph. What is ConfigR you may ask? As Adam elegantly pitches it: ConfigR allows you …[read more]

Dependency Injection in ASP.NET WebForms with StructureMap

Ahhh, the beautiful world of Dependency Injection (DI) trying to find it's way back in ASP.NET WebForms. What is it with me and ASP.NET WebForms lately? Just when I think I left all this behind, more and more work is thrown my way using this technology. ASP.NET forms has been around for a while and will also be an integral part of "One ASP.NET", so it is not a lost skill after all. I'm currently working on a major migration project bringin a 1.1 ASP.NET website to the 21st century-ish. All the …[read more]

Upload files in ASP.NET MVC with JavaScript and C#.

In an earlier [post](GHOST_URL/upload-files-to-the-server-using-javascript-and-mvc-webapi/" target="_blank), I described how to implement a file upload using [Ajax](" target="_blank) and [ASP.NET WebAPI](" target="_blank). This works great but it means that you need to have a WebAPI controller to manage the requests. If you already have a WebAPI in your solution then you can simply extend it to manage file uploads. However, there's no reason to add a WebAPI only for file uploads. Instead you can use an MVC controller …[read more]

Upload files to the server using Javascript and MVC WebAPI

The ASP.NET WebAPI is really versatile and powerful and I like to use it as much as I can when I develop for the web. I know that MVC controller methods can also process ajax requests, but I like the separation of concerns. WebAPI for REST calls and MVC for Views and the ViewModels manipulation. Note: if you still want to use MVC instead of WebAPI for your server implementation, have a read here. Recently, I had to implement a method to upload files to the server from an MVC view. I decided to use ajax and WebAPI. Once …[read more]

How to bind an Enum to a DropDownList in ASP.NET MVC

Prior to ASP.NET MVC 5, the only way to bind an enum to a drop down list in an MVC view was to roll out your own HtmlHelper, which is the best way to extend MVC's functionality. These days, with MVC 5 at your disposal, you can bind any enum to a view control easily by calling the "oh so handy" EnumDropDownListFor HTML helper. Details on the helper can be found here and works like any other build in HTML helper, with a model, a model property and a bunch of additional attributes that allow you to …[read more]

An introduction to the Common Logging API for .NET

Most developers know that logging is an invaluable tool especially when trying to troubleshoot issues with code running on production. In .Net, there is a plethora of tools to choose from such as Log4Net, nLog, Elmah etc. Each tool has its pros and cons so the decision on which one to use is usually based around the project requirements, complexity, performance and so on. What the [Common Logging API]( target="_blank) brings to the game is a lightweight “infrastructure” logging platform that allows developers to focus on the logging requirements instead of the …[read more]

Working with Azure Blobs through the .NET SDK

Azure is my cloud of choice. Not only because you get free stuff, yes you do, but also because of the flexibility and ease of interacting with it. If you don’t have an Azure account, you can register for free here. One of the features offered by Azure is Storage. There are 3 types of Storage: Blobs: used to store files, images, binary data, or video Drives: which can be mount on VMs etc like an external drive but virtual Tables: scalable structured storage which acts like a database table but with slightly different behaviour and structured. You can …[read more]

The right way to implement password hashing using PBKDF2 and C#

Following from my previous post about hashing using BCrypt and in response to some comments I received on Google+, I decide to provide an alternative hashing implementation using PBKDF2. As you will notice, the implementation is somewhat bigger than the one provided for BCrypt but in effect, both code segments perform the same task. First we create a hash from the plain text password and then we validate a password against the stored hash. NOTE: The constants, like the iterations, can be changed to tweak the hash strength. The code above is pretty self explanatory. You call PasswordHash.HashPassword(plaintext) …[read more]