C# When to use Ref vs Out

Interesting question asked of me today by another developer who was fairly new to C# and that was

What’s the difference between ref and out?

Well it’s a good question and it took me a minute or two to remember but once I had remembered (and supplemented my knowledge thanks to a bit of Googling) I thought I’d add the answer here. Continue reading

Allow dashes within urls using asp.net MVC 4

UPDATE: This applies to MVC 5 too

I was kind of surprised recently when I wanted to create an asp.net MVC view with dashes in it and found out that I couldn’t.

To me, reading-a-url-like-this is better than readingaurllikethis so I thought there must be a way to get around this. After all, web apps like WordPress and Umbraco allow this so why can’t I just do it in asp.net MVC?

After doing a bit of research on the subject I found out that I needed to do a couple of things Continue reading

Overcome Google Map resize issue within an AJAX tab container

I’m currently working on an existing website for a client and one of the requirements I’ve been given is to place an instance of a Google Map within a Microsoft AJAX Toolkit tab container.

This was easy enough but during testing I noticed that in some cases when I moved away from the page and then returned to it, the map was only displaying in the top left of it’s container div.  Upon  closer examination I found out that the only time this was happening was when the active tab index of the AJAX tab container was being set in code behind Continue reading

using Statement

A question I’m asked from time to time is why and when should I use a using statement within my code.

For me, using statements are all about convenience.  They provide a nice simple way of ensuring that I am using IDisposable objects correctly, plus I also like tidy code.  What’s an IDisposable object?  It’s an object which implementes the IDisposable interface, which from a coding perspective means that you have access to a .Dispose() method Continue reading

.Net DNS Lookups

DNS lookups.  Generally a pain and difficult to do in .Net.  The built in Dns class from the System.Net namespace provides a nice way of resolving an IP address or host name via its GetHostEntry() method but if you want to delve a little further into the DNS record then you’re screwed.

As a fan of nuget I thought I would take a browse through its repository and see if anyone had written a nice wrapper class that could help me out. Continue reading