Mike Rouse

Personal blog about software, current affairs, and family life

A free introduction to ASP.NET MVC 5

A free course published August 2014 gives a brief introduction to ASP.NET MVC 5.

A warning: It's a recording of a live session, so there's no editing out when things go wrong, and something does go wrong in the second video, which can be a bit distracting. Keep with it though, it is worth it.

You can get it free from here:


I have downloaded all the episodes as MP4s and streamed them to my TV, so I could relax and watch over a coffee. I kept getting the urge to try and follow along with Visual Studio in front of me, but actually this one is best enjoyed by just kicking back.

Direct MP4 URLs:

  1. http://video.ch9.ms/ch9/a44c/d57e542a-665a-4fdd-a29a-12c606fda44c/IntroASPNETMVCM01_mid.mp4
  2. http://video.ch9.ms/ch9/8092/e90034f1-7e3a-4ba7-ab14-e00c39498092/IntroASPNETMVCM02_mid.mp4
  3. http://video.ch9.ms/ch9/0f82/bda7e4c2-4ed9-49bb-9cc1-a19684860f82/IntroASPNETMVCM03_mid.mp4
  4. http://video.ch9.ms/ch9/0f92/b615d1df-837d-4d00-9287-5399850c0f92/IntroASPNETMVCM04_mid.mp4
  5. http://video.ch9.ms/ch9/f6f2/1449a56c-bfc7-420c-a88a-f18fee75f6f2/IntroASPNETMVCM05_mid.mp4
  6. http://video.ch9.ms/ch9/f071/138690e1-91f4-44a4-bdbf-28ecfa5cf071/IntroASPNETMVCM06_mid.mp4
  7. http://video.ch9.ms/ch9/6311/bf554fd5-15b4-4419-8b29-83aab1e86311/IntroASPNETMVCM07_mid.mp4

What does the Scottish Referendum mean for the West Midlands?

Despite my well-renowned tendency to always back the wrong horse I was right to 'predict' a victory against independence for Scotland. I use the term lightly because who am I to predict such things!

I do feel that I am witnessing living history right now, not just on the referendum point but on the wider constitutional issues. I feel there is a real possibility we could end up with a federal system to make up the UK of the future, or some other changes that mean my beloved West Midlands will have far more powers and controls over its own destiny.

However, I also suspect the old Westminster establishment is going to stitch us up. If that does happen, I for one will be extremely angry.

We, the people of the West Midlands, are tantalisingly close to getting the powers and responsibilities we need to further boost the region, which will allow us to invest in businesses, to tailor social services to our needs, and to create the kind of region that will be able to compete with London even more fiercely than the excellent job we do right now.

I have my own various thoughts and ideas on all of this, and little more right now, but one thing is certain: Scotland has awoken in me an interest in politics and the constitution I thought I had lost years ago. I suspect I am not alone.

Scottish Referendum

I am betting on a 'No' vote in tonight's results, but I could be wrong.

I'm basing my prediction on the recent efforts by the 'No' movement to seed just enough doubt into the mind of voters. It came very late, but I think it will be just enough to sway the undecided voters. 

However, I do believe that supporters of the status quo tend to stay at home on polling day unless they've got a good reason to defend the status quo. Has enough been done to persuade them to get out and mark 'No' on the ballot? Seeds of doubt, I would argue, might not be enough to convince someone to turn out and vote 'No' but to instead stay at home. Then again, could the level and quality of engagement be enough? Could it be people turn out more to be part of some big historic event rather than a genuine passion either way - to say 'I was there when...' and 'I did my bit'. In that case, I suspect some minds might not be made up until pencil is in hand. 

Another point - the working class and the so-called underclass. I think the election lies with them. I would argue these people are often beyond the reach of polling companies. They're at work when they call for starters. Even an evening call is likely to be greeted with, "we're having our tea!", and that's assuming the household is on the pollster's database in the first place.  If these groups turn out I believe it is more likely to support independence.

Of course, this is all guess work and personal hunch without much to base it on whatsoever apart from personal experience. We'll have to wait to see.

But, if pressed I would say it's likely to be a 'No', but only just. If that's the case it's going to be a 'Yes' next time - and there will be a next time despite Clause 30 of the Edinburgh Agreement.

Worksheet.SaveAs Method Doesn't Work

I hope this can save you the time I wasted trying to get this to work.

You cannot call Worksheet.SaveAs() with the aim of saving a single sheet from a workbook. You can only call the .SaveAs() method on a workbook. 

MSDN suggests you should be able to call .SaveAs() on a Worksheet: 

Saves changes to the chart or worksheet in a different file.

MSDN is wrong.

To work around this you need to copy the sheet to a new workbook and then call .SaveAs() on the newly created single-sheeted workbook.

How? Go here: StackOverflow

Hat-tips to: Tim Williams and "I love my monkey"

My Ice Bucket Challenge

I nominated:
  • Allan Andrews
  • Karl Bailes
  • Harry Cole
  • Chris Smith
  • Andy Ball
Allan says he can't do it as it'll worsen his ankylosing spondylitis, so I asked him to nominate someone else. He nominated my wife. Karl is also unwell so I suggested Seb Elliott do it for him instead to try and get my revenge on Seb for my stag night. Seb had already done the challenge but I didn't know. Harry Cole has been very quiet on the topic. I don't think he's the type to pour ice water over his head. Chris Smith was a sport and did his. Andy Ball has been very quiet also, but I feel more comfortable about pestering him. 

Where can we afford to live?

I used a tool available from the BBC website to ask, "Where can we afford to live given our situation?"


The answer was: nowhere.

At the moment we have no deposit money saved up to be even close to affording anywhere. If we want to stay within a few miles of the West Midlands we will need at least £20,000 to put towards a deposit to get a 90-95% loan-to-value mortgage.  That's right - £20,000 will only get us roughly 10% of our property depending on the exact location. 

It is actually cheaper for us to keep renting right now. To get a 3 bed house in our area as a property owner would cost us nearly £200 more per month.

The 19th of August 2014 is a date in my personal history now - it's the date I gave up aspiring to property ownership. For people like me it's nearly impossible now.

Getting your phone to text your wife when you leave the office, unless you want to go to the pub first

I have been playing with Microsoft's OnX platform. It allows you to write "rules" for your phone using JavaScript. You need OnX installed on your device first.

My first rule was a bit of a disaster because I couldn't get the scheduler to work properly, but I've had another go tonight and managed to come up with something.

This rule detects when you are leaving your office and goes to send a message to your wife (or partner). You know, one of those cuddly sweet messages. That is unless you want to stop the message going off for some reason. Maybe you're not going home. You might be just nipping to the shop... or you could be going to the pub. So... you have 30 or 60 seconds to stop the message going out. 

The rule can be installed on your phone right now via this link:


For the coders amongst you it's here:

// Initializing variables 
var contact = { name : "my wife",phoneNum : "+111222333444" } ;
var myMessage = "Heading home. See you soon xx";
var myLocation = { name : "the office",latitude : "40.78237915",longitude : "-73.96585846",location : "Central Park, NY" } ;
var myTimeDelay = "30" /* 30 seconds */;
// End of variables initializing 
var now = new Date().getTime();
var myTime = +myTimeDelay;
var wait = myTime*1000;
var later = now + wait;
var Abortion;
var region = device.regions.createRegion({
     name: myLocation.name, 
     latitude: myLocation.latitude, 
     longitude: myLocation.longitude,
     radius: 200
function checkForAbortion(){
    console.log("Checking for abortion");
    if (Abortion === undefined)
        device.notifications.createNotification('Sending SMS...').show();
            to: contact.phoneNum,
            body: myMessage
        function (err) {
            console.log(err || 'sms was sent successfully');
    else if (Abortion === true)
        device.notifications.createNotification('Cancelled SMS').show();
//Start the search
 region.on("exit", function() {
    console.log("Exiting Region");
    // Set a timer to check if user has supressed the message
      name: "cancellation", 
      time: later
     }, function(){
    // Ask for a response
    var notification = device.notifications.createNotification('Preparing SMS');
     notification.content = 'Leaving ' + myLocation.name + ': ' + myTimeDelay + ' secs to abort.';
     notification.on('click', function() {
         Abortion = true;
console.log("Monitoring for leaving the office");

Comments welcome

Personality Test

I recently undertook a personal test, the results of which aim to help people manage me and see how well I will integrate with an existing team. 

Some highlights included the following demotivating and frustrating factors:

  • Sharing responsibilities with others
  • Specialised problems requiring lengthy detailed work
  • Working without human contact
  • Having the same tasks to perform every day
  • Tight management from above
  • A restrictive and formally structured organisation
  • Having to spend a lot of time on 'people issues'
  • Feeling that I can do a job without thinking about it
I would largely agree with all of that. Whilst a team player I do believe in clearly defined responsibilities for each player in the team. If two or more people are doing the same thing it smacks of unnecessary duplication and I want to figure out why so much resource is needed for one area and look to see where improvements can be made. 

I do deeply resent tight management from above. I much prefer it when I'm given a set of objectives or deliverables and allowed to get on with it. My style can sometimes be unorthodox, but I get results. Tight management from above tends to squash my creativity. This tends to come in organisations where they have a formal structure, which I also dislike. I prefer to be able to move around an organisation on my own merits and not feel like there are layers of management between me and the senior management team.

Keys to maintaining my motivation and interest included:

  • Having a leadership role
  • Driving through ideas
  • Feeling challenged by the work
  • Constant variety
  • Being rewarded according to results
  • Working within a dynamic, informal environment
  • Meeting people inside and outside the organisation
  • Having the chance to be entrepreneurial

When it comes to managing me, the tips offered include:

  • Mike enjoys high profile positions of authority and responsibility
  • Mike likes to think big and to have power and influence over people and decisions
  • Mike needs to talk and be kept up to date with information - both official and 'the grapevine'
  • Offer Mike a forum to meet informally with colleagues to share ideas, problems and results
  • Keep an arm's length watch and be aware of Mike's capacity to be insensitive, to pre-judge and push others too hard
  • Mike's intentions are good but you need to make your support for activities clear
  • Give Mike firm but friendly advice by outlining the problem and let Mike produce a solution

I am beginning to sound like a politician!

The test is Facet5 and you can find out more here:

Offload your web.config AppSettings to another file - make life easier

I've been working on an old app and over the years the web.config file has become stuffed full of App Keys.  As the list grew, so did the time it took to deploy between environments as we needed to change a lot of the keys.

Step 1: Create a /common/config directory

Within our solution we've got a common place for all things config:

Step 2: Create environment-specific .config files

We have app.dev.config, app.release.config and app.staging.config.

Step 3: Use Config Transforms

Right-click on your existing web.config file and choose 'Add Config Transform' from the context menu. Note: You'll need Visual Studio 2010 as a minimum for this.

Step 4: Change your config file to outsource your appSettings Tell you web.config file that it must get its appSettings from elsewhere:

<appSettings configSource="common\config\app.dev.config" />

Step 5: Write a Transform Rule

Open up Web.Release.config and add something like:

<appSettings xdt:Transform="SetAttributes(configSource)" configSource="common\config\app.release.config" />

Step 6: Deploy!

When you deploy your app now, using the Publish option from the context menu, it will now transform your web.config file to point to the correct location for your release's app keys. This has been a massive time saver, even if a little labourious at first. Your DevOps team will thank you too as you won't need to dial into the server to change the config.

Newbie to Android Development

Though I have a web design and basic development background I have only been doing "proper" object-oriented coding for a couple of years, which has focused on ASP.NET.

Still learning, but thought I might fancy a bit of Android development to broaden my horizons.

I was advised to download Eclipse as this would be as close to Visual Studio as I could get. This turned out to be a painful experience as I eventually figured out I was running Eclipse in 64-bit mode but only had a 32-bit JRE.

I then had to add a plugin for Android development to Eclipse. This went relatively smoothly.

I then had to try and get an emulator running to show off my 'hello world' app. That was tricky. Eventually I got the right packages for an Intel processor and that seems to have sorted it.

Next, I just had to hit the 'Run' button and then choose 'Android Application'. Wait a second, no option exists for 'Android Application' from this run menu.

You get the picture.

So far almost every step has been met with environment and configuration difficulty. I only have a short window of time in an evening to explore this stuff and so far I'm into my second evening and haven't actually written a line of code yet.

There must be an easier way to do all of this.

I'm installing Android Studio as a new hope in all of this. Seems to be something a bit more modern anyway - not sure why the 'hello world' training didn't point to this tool sooner.

Ah. JRE isn't enough for this tool. I need JDK instead. Another environment and configuration hurdle!

What's that? My network is up one minute down the next? Damn you BT!

If I ever get to develop an Android app, you lot will be the first to know about it, along with the invitees to my 'I finally got to write some code party!'