In hopes to better understand the order of operators in C# (6 & 7, but most will work for lower versions too), I decided to make a cheat sheet for myself in a table format. The list / section on the MSDN was helpful, but I wanted something a little […]

Continus reading  

Ever need to group by a property and want to use LINQ to do so? Happened to me recently and decided to explore the really simple way to group objects using LINQ using GroupBy. I started off by creating a simple class for a person and created a list Next add the […]

Continus reading  

There has been a few times I’ve need to copy models to view models, or very similar classes to each other, but wanted to clean up the code in the process. The result of that is a start to a helper method below to “combine” objects in C#. Code will […]

Continus reading  

You may already be doing one or more of these tips, so this post might not be for everybody. But if you feel like you could improve your code even by a little bit, read on! Hopefully I can help make your code cleaner and easier to read. Also note, I […]

Continus reading  

Early in a work morning, debugging somebody else’s old code, and without coffee, I get the following error message and got stumped for 2-3 min (Hate to admit with my experience) : Member [MethodNamd] cannot be accessed with an instance reference; qualify it with a type name instead. While this error […]

Continus reading  

I needed a pretty reliable and easy way to get the client’s IP address in one of the applications I’m working on. Granted the IP is just used for log purposes, I still wanted to pull from the request vs using some JS. There are multiple ways to do this, […]

Continus reading  

After adding the AntiForgeryToken to prevent Cross Site Request Forgery, I started getting the following message when I was debugging the site “A required anti-forgery token was not supplied or was invalid.” With the following inner exception Validation of viewstate MAC failed. If this application is hosted by a Web Farm […]

Continus reading  

A very quick code snippet for you all today. I had encountered an issue where I needed to invert the text color from the background (color was changing consistently from the user). So after some googling and playing around, I created something to do just that for me. First we […]

Continus reading  

I needed a quick way to clear the cache when I was debugging an issue, and couldn’t seem to find anything that worked right away online. So, created a quick foreach to handle cleaning everything up. Short and simple, thought I’d post to help anybody else out having the same […]

Continus reading  

The Issue I ran into a strange issue with an ASP.NET site (MVC2 – 4.0 Framework) where when executing a stored proc, SqlDataAdapter.Fill(DataTable) will not return any rows some of the time, but SQL Server Management Studio will almost immediately return results. The full method calling the stored procedure is […]

Continus reading  

When doing some quick research on SQL Parameters with SqlCommand, I noticed two methods which seemed to perform the same task, SqlCommand.Parameters.Add() and SqlCommand.CreateParameter().  After looking into each method on MSDN, I noticed that CreateParameter() will simply create the parameter, while Parameters.Add() will create the parameter and add it to the parameter collection. SqlCommand.Parameters.Add() […]

Continus reading  

I was recently trying to send to Telerik’s image editing control a jpeg image in a stream format. I was checking for the other types and using the appropriate format providers, but I kept getting an exception when working with JPEGs : The image cannot be decoded. The image header […]

Continus reading  
%d bloggers like this: