Fast and Efficient C# and Visual Basic String Concatenation

If you do any sort of web development work on the .NET platform, you are going to find yourself concatenating (connecting) strings together on a very regular basis. There are two ways to do this. The first is with a traditional string concatenation, which would look something like this: string MyString = String.Empty; MyString = "Hello " + … [Read more...]

ASP.NET Performance Tip: Remove Unnecessary Library References

Over the last few days, I've been scouring the web for techniques and strategies to optimize ASP.NET code so that it runs faster and more efficient, resulting in quicker load times. A lot of what I found was pretty standard advice, disable viewstate, use the StringBuilder for concatenation, disable tracing and use AJAX. One piece of advice that I … [Read more...]

How to Display Your Twitter Feed using ASP.NET

UPDATE 3/23/2010 - Ricky from Twitterizer commented below noting that basic authentication will soon go away via Twitter and OAUTH will be required. Note that the code below will only work for a few months. We will post an updated code-example soon. As I write this article, It's about 75 degrees and Sunny outside. When I should be going out on a … [Read more...]

How to Implement an ASP.NET Color Picker

One of the components of the 360 Web Content Management System (website in progress) that I wanted to develop was an events calendar that allowed you to post events into color-coded categories. You can see a demo of it here. At first, I had it so that users would manually enter in a 6-character HTML color code, but it was very non-intuitive for … [Read more...]

How to Validate Email Addresses in C#

I was recently doing doing support for a client that had a newsletter system. The previous employee had neglected to do much in the form of format validation for email addresses from both a user-input standpoint and system-integrity standpoint. Since there were several email addresses in the database that didn't meet the basic conventions of an … [Read more...]

Hash Passwords in C# and Visual Basic Using SHA-512

We recently covered an easy way to hash passwords using SHA-1┬áin .NET using either Visual Basic or C#. In most cases, SHA-1 encryption is "secure enough", but there are some mathematical weaknesses. Microsoft's .NET platform (specifically the System.Security class) allows you to encrypt passwords with a number of differnet algorithms without having … [Read more...]

How to Authenticate a User in Active Directory using ASP.NET

If you're working in an academic or large corporate or government setting, changes are you're going to have a network in place using Active Directory or an open-source equivalent. Every user in the organization will have some sort of an account to use. If you're building an internal web-application or desktop-application, it doesn't make a lot of … [Read more...]

How to Resize Photos in ASP.NET

If you're developing a website that allows users to upload any sort of photos or images, you have to expect that they aren't going to bother doing any sort of basic image manipulation, such as resizing an 8 megapixel image down to something that's appropriate for the web. Fortunately, there are a number of good cropping and image resizing tools … [Read more...]

A Simple Way to Hash Passwords in ASP.NET

If you're developing a website that requires your users to create an account, it's a very good idea to not store their passwords in plain-text in the database. A good chunk of users use the same password for just about everything, so if your database is compromised, there's the possibility of having some real reprocussions for your users. … [Read more...]

ASP.NET Caching Techniques and Tools

One of the most frequent criticisms of the ASP.NET stack is that it's less efficient than some of its open-source counterparts. However, Microsoft has actually built in a lot of neat technology into the framework related to caching that allows for much more scalability than you might think. Not only is there caching support built directly into … [Read more...]