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

Pretty WordPress Permalinks on Azure

So I’m in the process of moving my company website to Azure and I’ve decided to create it using WordPress as I’ve enjoyed the experience of WordPress so far with this blog.

This blog is hosted for free by my good awesome friend Brandon (www.ganch.com) and so I haven’t asked any questions as to what platform it’s hosted on.  I’d assumed it’d be an IIS server but, as they say, if you assume something (insert terrible pun here).  So imagine my surprise when I popped down to the Permalinks section of my Azure hosted WordPress site and saw that my page links (note it’s page links only I’m referring to here folks, the blog posts were fine) could only be almost pretty.  Almost pretty?  WTF?  That won’t do because this site is presently the most important site in the world to me and I demand that it’s links be of the friendly variety. Continue reading

Aliases in SQL Server 2008

As far as I’m concerned remembering server names is a pain in the backside especially when you have no control over how they are named.  Is abc123.sql.domain.net the development environment, or is it the UAT environment, or is it production?

The good news is that you can set up aliases in SQL Server 2008 to help you out and it literally only takes a couple of minutes to do. Continue reading

Remove Recent Server List in SQL Server 2008

Having recently gone through the process of moving a number of databases to new servers I was met with the annoying issue of having my list of recent servers in SQL Server 2008 being cluttered with servers that were no longer active.  Although you can’t clear this list directly through the SQL Server GUI (apparently this is possible in SQL Server 2012) it is straight forward enough to get rid of your unwanted servers.

Before you start though, make sure all instances of SQL Server are closed. Continue reading

SQL Server SYNONYM

I’ve recently been working on an application which has to make use of data from within two databases (one onsite and one remote) with SQL generated to query the two databases along the lines of:

SELECT a.*, b.*
FROM [TableA] a
INNER JOIN [DatabaseB].[SchemaB].[TableB] b ON a.ID = b.ID

Referencing the second database using its full name is annoying to type but also limiting.  Imagine if you were working on a couple of projects, each of which used the same version DatabaseA, but which needed to reference different versions of DatabaseB.  If you were developing each of these databases in SQL Server you’d have to call the second version of DatabaseB something different which would end up breaking your SQL as it specifically references DatabaseB by name. 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