.NET Framework / C#
.NET Framework is a software framework developed by Microsoft that runs primarily on Microsoft Windows. It includes a large class library named as Framework Class Library (FCL) and provides language interoperability (each language can use code written in other languages) across several programming languages. Programs written for .NET Framework execute in a software environment named the Common Language Runtime (CLR). The CLR is an application virtual machine that provides services such as security, memory management, and exception handling. As such, computer code written using .NET Framework is called “managed code”. FCL and CLR together constitute the .NET Framework.
How to add dynamic compilation to your C# projects?
Dynamic compilation is an awesome feature to add to your projects. Especially frameworks will benefit from the compilation of dynamic expressions and scripts. There are two main ways of doing it: the Code DOM Compiler or the Roslyn project. In this blog I will show how to implement them both.
Auto fill settings objects with .config values
Lately I’ve been playing around with some API’s. Most of them need a bunch of settings that I’m storing them in my config files. I found myself doing the same work over and over again: creating a settings class, filling the class with information and using it. So I came up with a way to leverage reflection to fill my setting classes with .config values.
How to download a URL and get its MIME type using the C# WebClient?
A while back I needed to download a URL and determine the MIME type. Fortunately many web servers will send the MIME type of the resource back to the client (so browsers even require it). Here is a snippet of C# code that does the trick.
Fixing IE Quirks Mode in ASP.Net
Quirks mode refers to a technique used by some web browsers for the sake of maintaining backward compatibility with web pages designed for older browsers, instead of strictly complying with W3C and IETF standards in standards mode. Here’s how to force IE into submission by adding a DLL to ASP.Net.
A (slightly) better WebClient class supporting cookies and headers
Sometimes you’ll need a (slightly) better C# WebClient that’s able to store/retrieve cookies, prevent redirects or retrieve the HttpStatusCode of a request. I’ve created a small class that facilitates these features.
How to scrape a photo from a Twitter Photo URL with C#
Twitter uses its url shortener to place photo’s in Tweets. I’ve tried processing these URLs in the browser, but cross site scripting measures prevented me from processing the result with jQuery.
I decided to resolve it in C# (as I’m using ASP.Net). The following script leverages a WebClient and a regular expression to extract the photo URL from the shortened URL. This code could be added to a handler or a webservice that can be called from script.
Seek Position of a String in a File or FileStream
Yesterday I was working on a little bit of code to sniff out some XMP without having to worry about reading a file at a certain pre-defined position. XMP, being just plain XML, can be found by matching a string. After some googling I’ve found out that…