Development tip - Try using Visual Studio Code Snippets

If you haven't been programming in visual studio for long, chances are you haven't heard about code snippets.

Code snippet is actually code which you can quickly insert into the code editor. Typically snippets are common language constructs which you use often and a number of them come bundled with VIsual Studio. You probably noticed them in IntelliSense as you were typing code.

As the tooltip says, you can simply go to code snippet and then hit TAB key twice to insert it.

Some useful C# snippets are:

  1. #region - Inserts #region and #endregion, puts a cursor where you would normally type the name.
  2. try - Inserts a try-catch
  3. tryf - Inserts a try-finally
  4. for and forr - Insert for and reverse for loops
  5. prop - Inserts an automatic property
  6. propfull - Inserts a property and a backing field

As snippets for these short constructs exist, there are also snippets for entire classes and methods. And you can also create your own. To see all snippets that are shipped with Visual Studio, simply go to Tools -> Code Snippets Manager...

This nifty little thing is also available in Visual Studio Community Edition. You can play with the snippets, download new ones from the Internet and if you try to get into a habit of using them, possibly even improve your coding practices.

In a future blog post we'll create a small code snippet of our own.

Happy coding!

Introduction to URL Rewriting using IIS URL Rewrite Module and Regular Expressions

In this blog post we'll talk about URL Rewriting and how it can be done using Microsoft's IIS. Why IIS? Because there are not that many tutorials that cover that stuff. Also, some very experienced PHP developers don't know how to rewrite URLs if their page is hosted on IIS.

URL Rewriting?

URL Rewriting basically means: altering the URL's apperance without affecting behaviour of your site. But why would someone alter the apperance of an URL?

Well, there are couple of great reasons. First, of course is Search Engine Optimization (SEO). For example, compare the following URL:

http://localhost.com/blog.php?id=1

With this one:

http://localhost.com/CSS-shorthand-properties/1

What are the advantages of URL number two? It's friendlier to both users and search engines. Users can immediately tell what the blog post is about and it also helps your site to get better search engine rankings.

More...