Category: LINQ

Block access to images from other websites

In ASP.NET you can write HTTP Modules to perform actions inside the request pipeline before the request is being finally processed. In this example we use an HTTP Module to check whether the REFERER header matches our website. If it doesn’t then we won’t allow access to the resources. By doing this we can simply




Create your own extension methods to use in LINQ

The possibility to create extension methods has been around for some time in the .Net Framework. It basically gives you the possibility to extend a class with new methods without having to create a new class that extends the original one. If the original class is sealed you can’t even extend the class, but you




Complex syntactical sugar using yield in C#

Yield is one of the available contextual keywords in C#, meaning it has a purpose in the code but it’s not a reserved word. Microsoft defines yield as being: Used in an iterator block to return a value to the enumerator object or to signal the end of iteration The keyword was added in .NET




%d bloggers like this: