How to calculate age in C#

How to calculate age in C#

Today I had a requirement to calculate someone’s age based on that person’s birthday. It seems like a pretty simple function to write, but I decided to Google around a little bit anyway to see if what other people were doing to calculate age based on...

Set The Active Class On Bootstrap Nav Links In MVC

Here’s a quick way to set the active class on the current URL with a .Net MVC application. 1. Set a string variable equal to the request path at the top of the layout or view: @{ string path = Context.Request.Path; } 2. Check the path variable against whatever...
Redirect A Url To An External Domain In Umbraco 7

Redirect A Url To An External Domain In Umbraco 7

One of my clients has an Umbraco 7 site that pretty much takes care of itself other than a few minor content updates here and there. Today that client asked we set up a redirect from an internal URL to an external domain for their job postings. Normally this is an...

Convert A Generic List To CSV File In C#

This is an example of how to convert a generic list to a dynamic downloadable .csv file using C#, the CsvHelper library and the FileStreamResult. Download the repo and run the full project solution from Github In this example a request comes into the controller, we...