find a location for property in a new city

Wednesday, 31 March 2010

Visual Studio 2010 release date. Be the first to know!


Get the Visual Studio 2010 release date and exact time!

What to know the release date for Visual Studio 2010? Want to know the minute VS2010 is released to MSDN subscribers? Here's how.

I had to speak to Microsoft recently to calm my anticipation. I've been using the RC for a while now but am not confident to launch to production with it. I am still waiting for Visual Studio 2010 to be released.

The kind people at MS provided me with a MDSN subscription downloads RSS. You can use this feed to keep up to date with what has become available in the downloads centre.

I know it will be launched on Monday 12th April 2010 so you can expect it by then. But if it is released before that you can find out with the MSDN downloads feed:

Follow britishdev on Twitter

Tuesday, 30 March 2010

Add canonical hint to all your web pages in one go

Want to use canonical URLs in all of your web pages for SEO but feeling lazy? Have some ASP.NET/C# code to save doing it yourself for each page.

You will need to paste this into a base page or a master page and then simply call it when needed.
public void InsertCanonical(string canonicalUrl)
  //if no url was specified just make the canonical the exact url of this page minus querystring
  //i'm also removing the default.aspx which you most likely wont need to access this page
  if (string.IsNullOrEmpty(canonicalUrl))
    canonicalUrl = "http://" + Request.Url.Host + Request.Url.AbsolutePath.Replace("default.aspx", "");
  //if there is a relative url is provided (i.e. host is NOT provided) add it in plus http protocol
  else if (!canonicalUrl.Contains(""))
    canonicalUrl = "http://" + Request.Url.Host + canonicalUrl;
  //if the canonical does NOT begin with either http or https protocol add it in
  else if(!Regex.Match(canonicalUrl, "^https?://").Success)
    canonicalUrl = "http://" + canonicalUrl;
  //create the canonical link and add it to the page headers :)
  var link = new HtmlLink();
  link.Href = canonicalUrl.ToLower();
  link.Attributes.Add("rel", "canonical");

Most times you simply want to use pass null as the parameter just to truncate some ugly tracking querystring paramters off of your URL. So you may appreciate this override too:
public void InsertCanonical()

Follow britishdev on Twitter

Monday, 29 March 2010

There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined

I managed to get "The requested page cannot be accessed because the related configuration data for the page is invalid." errors with a config error of "There is a duplicate 'system.web.extensions/scripting/scriptResourceHandler' section defined" after trying to be clever. Here is the problem and solution.

Keen to try .NET4's new arsenal but trying to create physical separation from my current .NET3.5 (.NET2 runtime) solution, I decided to create a new ASP.NET MVC2 project and use a virtual application in IIS7, set to use the .NET4 application pool to make it appear on a /mvc subdirectory rather than an entirely new site.

Then my old friend "Yellow Screen of Death" reared his, quite frankly, ugly head and started hurling abuse at me for defining duplicate sections. He has no subtlety.

Well he is lieing! I have not added duplicates. This ungoogleable problem was causing me grief because of some complete falsity. I removed the "duplicate" from the web root web.config and then it had a problem with the next defined section. Then the next and the next. I removed them all and then it got its knickers in a twist about something else.

Time to take a step back

What am I trying to do? Run a .NET4 application from a .NET2 runtime... oh right... yeah.

I stopped my quest and started a new site in IIS for this MVC2 application, now all is well. Those errors were complete red herrings though and I suppose my head wasn't quite in gear since it was late on a Friday and there was drinking to be done!


If you are still struggling with this and you aren't using .NET v2 and v4 together there is still more help in this post about solving web.config inheritance.

Update 2:

If you are using .NET 4 as a child to a .NET 2 parent application then you will need to read this to solve all your problems :) ASP.NET 4 Child Applications Fail to Start When Under ASP.NET 2.0 or ASP.NET 3.5 Applications

Follow britishdev on Twitter

Hilariously imaginative SQL injection attack!

Looks like Little Bobby Tables has grown up now and modified his car with an optimistic SQL injection attack. Try inserting that registration number into your database DVLA!

Nice work Gizmodo

Follow britishdev on Twitter

Wednesday, 24 March 2010

The browser or gateway element with ID 'Safari1Plus' cannot be found. Upgrading to .NET4

I received an error message of "The browser or gateway element with ID 'Safari1Plus' cannot be found." and a description of "An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately."

This is because the browser definitions that were (appreciatively) borrowed from Ocean's Place are inheriting from definitions that existed on the .NET framework v2 and no longer exist on v4.

There are two ways around this:
  • Replacing all the definitions from .NET4 with the old ones from .NET2
  • Remove Ocean's definitions

Through personal preference I decided to remove the 3rd party definitions as I would assume .NET4 has covered the new browsers/crawlers missed by the 5 year old .NET2 by now.

Replacing all the new definitions with the old ones worries me as we’d getting out of sync with the expectations of the framework, which will affect service pack updates to these definitions.

Follow britishdev on Twitter

Unrecognized attribute 'targetFramework' when upgrading to .NET 4

I received and error saying "Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive." with a description of "An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately."

Unlike .NET v3 and v3.5 which were essentially extensions to v2. .NET4 is an entirely self contained brand spanking new (and much lighter) framework. As such you will need to change your application pool like so:

Go to IIS and find the Application Pool you are using. Right click it and select Basic Settings then simply change the target framework to .NET Framework v4 as illustrated.

Follow britishdev on Twitter

Monday, 22 March 2010

Visual Studio 2010 release date delayed


Get the Visual Studio 2010 release date and exact time!

The release date of Visual Studio 2010 was 22nd March 2010. However, due to performance issues mainly with virtual memory usage it has been pushed back "a few weeks." Overall this sounds like a good thing as we will end up with a delayed but higher performing product.

The launch date of 12th April 2010 still stands, so I assume we can expect it by then (at the latest). Remember, a release date is different from a launch date (launch is always the later of the two).

So I am sitting here on 22nd March 2010 having a much less interesting day than I was expecting.

Follow britishdev on Twitter

Wednesday, 17 March 2010

Delete duplicate rows using CTE and ROW_NUMBER in SQL 2005

Ever had duplicate rows in your table because you forgot to use a 'Unique' contraint? Finding it hard to delete the duplicate rows as not all of the columns in the rows are the same? Well you can use two of SQL Server 2005's new features to overcome this problem.

I'm going to create a table with duplicate rows to demonstrate this problem:
CREATE TABLE CustomerEmails
  ID int IDENTITY (1, 1),
  CustomerID int,
  Email varchar(100),
  CreatedDate smalldatetime

INSERT INTO CustomerEmails
SELECT 135, '', '2010-03-31' UNION ALL
SELECT 267, '','2010-03-21' UNION ALL
SELECT 222, '''2010-03-11' UNION ALL
SELECT 333, '''2010-03-01' UNION ALL
SELECT 333, '', '2010-02-28' UNION ALL
SELECT 333, '''2010-02-21' UNION ALL
SELECT 222, '', '2010-02-11' UNION ALL
SELECT 492, '','2010-02-01';

So customers 222 and 333 are in there multiple times and if I do a lookup to find their email I get multiple results. Someone has been inserting new rows without trying to update existing rows first... the lunatic!

I remember a DBA faffing with this problem for ages. After realising you can't DISTINCT a single column, trying to DELETE WHERE and ID exists IN a GROUP SELECT statement HAVING COUNT(*) > 1 except for the TOP row with an ORDER BY on the date DESC... *yawn*

Well, here is the way for cool people to do it: You create a CTE using a column for a ROW_NUMBER() to count the number of duplicates for each customer:
WITH Duplicates AS
    ROW_NUMBER() OVER (PARTITION BY CustomerID ORDER BY CreatedDate DESC) as cnt

The ROW_NUMBER() has a partition on CustomerID which means the count will start again for each customer. I have oredered the count by CreatedDate DESC too which means the row with a count of 1 will be the newest.
Now you simply DELETE from the CTE where the count is higher than 1, removing all the duplicates:
  cnt > 1;

Have a look:
SELECT * FROM CustomerEmails;

Great! You no longer have any duplicates! Now quickly whack a UNIQUE contraint on that column before that lunatic developer starts messing with your data again.
ALTER TABLE CustomerEmails ADD UNIQUE (CustomerID);

Follow britishdev on Twitter

Sunday, 7 March 2010

Waiting for VS2010 release date to come. Not long now...

I work on quite an agile environment at work and so it is possible to investigate an upgrade to .NET 4, Visual Studio 2010 etc. In fact I have been asked to investigate such a change (just finding time is the issue).

Of course I am keen to get moving with this but I'm not confident about pushing a change to a platform that is still in release candidate. To be fair, the latest release candidate does come with a "go live" license so if you are confident enough you can download it here. Due to me not being willing to upgrade my work's infrastructure to a release candidate I will wait until Monday 22nd March 2010 when it is released. Launch date is April 12th.

I noticed something though: It seems I've been doing a lot of waiting recently.

There are a lot of technologies that I am interested in and have been patiently waiting for that either come with this VS2010 release or co-incidentally release around the same time:
  • C# 4.0 (22/03/2010)
  • ASP.NET 4 (22/03/2010)
  • Visual Studio 2010 (22/03/2010)
  • SQL Server 2008 R2 (by May 2010)
  • MVC 2.0 (with .NET 4)
  • Entity Framework 4 (with .NET 4)
There is Siverlight 4 too (but I am not interested :P)


The release date has been delayed until at least the launch date of 12th April 2010. Which you can read about here:
Visual Studio 2010 release date delayed

Follow britishdev on Twitter

Wednesday, 3 March 2010

London Bridge is burning down! I'll work from home

Today I arrived at my local train station set for my 15min journey into Central London only to find all my trains were cancelled due to a fire at London Bridge station. I found the only alternative was a 2 hour big red bus journey guarded by a mosh pit of people fighting for the one or two spare standing spaces.

With our modern world I don't need to be at work to do my job. I can easily fire up the VPN and do my development work remotely. So I gave my boss a bell. He is very understanding and having a development background he understands the advantages of working from home on occasions and so he granted my request. Despite his understanding, however, the company wide policy is to only allow working from home in emergencies and so had to explain his reluctance.

I can understand a company wide default policy of 'work from home only in emergencies' but am not sure it should apply to developers in all instances. Most people where I work cannot do their job from home. Many of the staff depend on meetings and interaction. Conversely, meetings and interaction mostly prevent me from working and so I have relatively very few.

Of course I need to be at work most of the time. People need me to estimate technical solutions and timescales and I need to be on hand generally. I can't just put my head down and write code all the time (as much as I'd love to). Today I worked from home and I am not joking when I say I got through work estimated at almost 20 hours in the space of my standard 7.5 hour day.

I suppose the problem is if the developers I work with are allowed to work from home on occasions then everyone will want to. Then there will be at least one person taking the piss - there always is.

With development having such a tangible metric (e.g. code commits to source control, features materialising) and there being the huge advantage of being able to pump out huge amounts of work more than usual due to lack of distraction can there not be some compromise?

Follow britishdev on Twitter

Tuesday, 2 March 2010

Why should I make a developer blog?

About 3 years ago a friend of mine I used to work with told me he was going to make a developer blog. He planned to put all the interesting discoveries he made whilst going about his day job coding ASP.NET/C# into a blog.

So I did what's right; I called him an idiot and took the piss out of him for having such a stupid idea. He is a mate after all. Anyway, 3 years on and I'm starting to think he could have been on to something. I mean blogging has caught on somewhat...

I too am a (predominantly) ASP.NET/C# and SQL developer and I have been doing this work intensely for about 4 years now. I could not have got anywhere near the level of experience I have if it weren't for the plethora of blogs and forum posts a mere Google away.

So I have everything I need; why should I make a developer blog? I know I make interesting discoveries that other developers can benefit from but how does that help me?! I know this is incredibly selfish and we'd all be worse off if everyone subscribed to this viewpoint but even still this is my spare time we're talking about and there is beer to be drunk.

I'm still not 100% sure why I should start a developer blog at this point if I'm honest. However, here are a list of reasons that have motivated me to come this far:
  • I often work out solutions to problems myself after intensive Googling has failed me. It must be criminal to sit on these secrets
  • My use of blogs so far is almost entirely selfish and that is just being rude
  • I must be getting older (currently approaching 26) because I can feel irresponsibility slipping through my fingers
  • I'm proud of my work so why not show it off
  • I can forget the solutions to problems I have previously solved. This is good documentation too!
  • I would be so so happy with myself if I started to get the feeling I was helping people
  • I think writing a blog that really actually helps people is a new and massive challenge for me. I'm really interested to see if I can do it
  • I would take great pleasure to see people reading and commenting on my posts. Absolutely love it

On that note, please feel free to comment on this post if you can think of any other motives for blogging or if you have any feedback for my first post :)

Follow britishdev on Twitter