Configure DNS Aliases in IISExpress for localhost

A direction we are taking Process PA is white labelling for our partners. To do this we are still hosting on the same scalable platform on Microsoft Azure and essentially adding another level of multi-tenanting in our codebase. When a user navigates to they will get our first party branded experience. However, when a user navigates to something like, they will get a tailored experience complete with branding, different resources, templates and features specific for those customers supported by our partners.

Building out the experience using Dependency Injection with Branch By Abstraction based on the host is reasonably straight forward. I however wanted the local development environment to be run in the same way, rather than switching in code for whatever partner experience was being built out at the time. To do this I need to be able to configure local DNS records for localhost and IISExpress. The answer I found on StackOverflow but below are the simplest steps that worked for me.

  1. Open Notepad as an Administrator
  2. Open in Notepad C:\Windows\System32\drivers\etc\hosts
  3. Copy the comment lines for localhost host and add as your DNS records    partner1.localhost
    ::1          partner1.localhost
  4. For Visual Studio 2015, open <Solution folder>\.vs\config\applicationhost.config
  5. Find the site and add the bindings you need, making sure to change the ports.
    <binding protocol="http" bindingInformation="*:1704:localhost" />
    <binding protocol="https" bindingInformation="*:44300:localhost" />
    <binding protocol="http" bindingInformation="*:1705:partner1.localhost" />
    <binding protocol="https" bindingInformation="*:44308:partner1.localhost" />
  6. To prevent the need to run Visual Studio as admin to start IISExpress on those ports, open an Administrator command prompt and run:
    netsh http add urlacl url=http://partner1.localhost:1705/ user=machine\username
    netsh http add urlacl url=https://partner1.localhost:44308/ user=machine\username

If you have certificate trust issues check out:

And that’s it! When you go to https://localhost:44300 or https://partner1.localhost:44308 you get the same application with a different experience.

Unexpected Bots and reCAPTCHA defense

A few weeks ago I soft launched my product to allow for direct sign ups from the public web site, Process PA. We’ve been running for a few month with just our foundation customers making sure things are running well before letting anyone register without interaction. I updated the web site without announcing to just test the process a bit before (hopefully) driving more traffic to the site.

Interestingly, I started getting random sign ups registered in the database. Many had even verified their email address. I hadn’t been directing people to the site yet and where we are now we don’t get many unknown visitors. Sure enough, it appears they are bot accounts. Quite surprising that bots are onto new sites quickly and filling out registration forms. I’m not sure what they expect out of it.

CAPTCHA Required

This is kind of a pain. While building a startup I have many things to do. And stopping bots this early on I didn’t think would be required. Fortunately putting CAPTCHA in place is pretty quick. However, I started using a very popular NuGet package BotDetect CAPTCHA. Although implementing was easy it results in those horrible user experience that everyone hates. I did not want to add any friction to legitimate sign ups.

Although the BotDetect CAPTCHA claims “not one confirmed case of automated CAPTCHA breaking by spammers” I’m sceptical. I did a thesis on vision processing over 10 years ago and it’s gotten much better since then. Spammer may not be breaking them, but Google states, “it can decipher the hardest distorted text puzzles from reCAPTCHA with over 99% accuracy”.

Google No CAPTCHA reCAPTCHA to the rescue

You’ve seen it across many websites now. Launched December 2014, this provides the simple ability for the user to check the box that says, “I’m not a robot”. And they are, most of the time, done. So much better for the user. So much harder for the bot.

Implementing is very easy from the instructions on the admin site which contains your keys. Get started at Google reCAPTCHA. Client side is a script include and a div. Server side is a web request. It is even simpler nicely wrapped up as an attribute from the NuGet package reCAPTCH.MVC with clear instructions on their project site.

With it all in place now, it looks like I’ll be needing human customers to keep up the sign up rate now that the bots aren’t allowed in. If you are tired of doing minutes and governance manually for your association, club or board come and try out Process PA.

Database unable to be recreated after delete with Entity Framework

Nice little gotcha when getting started with Entity Framework using the built-in ASP.NET MVC templates. Wanting to start from a fresh database using the MSSQLLocalDB there is a few little things to do that aren’t necessarily obvious:

1. Delete the mdb and ldf

Go to the App_Data directory and delete.

If the delete fails, make sure you stop IIS Express which is holding a handle to the files.
Stop IIS Express

If the delete still fails, make sure you have closed connections in the server explorer in Visual Studio.
Close Server Explorer Connection

Still failing to delete? Go to Task Manager and kill the SQL Server Windows NT [sqlservr.exe] process.
Kill the process

2. Run Update-Database from the Package Manager Console


Fails with “The EntityFramework package is not installed on project ‘####’.
Check the default project is set to the correct one which contains the Migrations folder. Mine keep defaulting back to the Tests project.

Fails with “Cannot attach the file *.mdf as database”.
I found the answer on StackOverflow. The default connections string contains the Initial Catalog property. Which is all good for a full SQL Database but not LocalDb. Removing that property and it is all good.


Entity Framework seems quite good with Code First Migrations. I find the documentation really hard to get up to speed if you are coming new to it. Much of the documentation seems to focus around the difference and pieces together what to use for the latest version wasn’t the simplest. There is a bunch of little things you need to be aware of and practice with Add-Migrations and making sure everything is upgradable properly. Persisting with it [pun intended] has been worthwhile so far…

Capture IIS Network Traffic in Fiddler

I have an IIS application that is querying Azure Active Directory Graph API from the server. I wanted to capture what is requests are happening using the client API. By default Fiddler does not capture these requests. Fiddler inserts itself into the WinINET layer as a proxy which is bypassed by IIS outgoing traffic.

To capture these requests  coming from an IIS application pool. Add to your web.config after the <configSections> element:

    <defaultProxy enabled="true">
      <proxy proxyaddress="" bypassonlocal="False"/>

where 8888 is the fiddler listening port, found in Tools > Fiddler Options


This can be found in the Fiddler documentation.

Happy web traffic debugging!

Adding Microsoft PubCenter Ads with AdDuplex fall-back on Windows Phone 8

DVLUP has a challenge Shamelessly promote your apps with AdDuplex. AdDuplex doesn’t earn you any income so why would you want to give ads to your users without any benefit to yourself? AdDuplex answers this succinctly “According to reports the average fill rate in mobile ad networks could be as low as 10%. AdDuplex helps you utilize 100% of your ad space, so even when you are not making money from the other ad network you get free promotion for your app.”

It is encouraged to use an ad network with fallback to AdDuplex and It only takes 5 minutes to add to your app.

  1. Add references to Microsoft Advertising and AdDuplex
    a. Install Microsoft Advertising SDK, if not already, and add reference
    Reference to Microsoft Advertising SDK
    b. Install AdDuplex via NuGet Package. Enter into the Package Manager Console:
    Install-Package AdDuplexWP8
  2. Add references to the namespace in your Xaml page you want to display the ads

  3. Add controls so that the AdDuplex banner is under the Microsoft Advertising banner.  
    <adduplex:AdControl x:Name="adDuplexAd" AppId="12345" VerticalAlignment="Bottom" />
    <ad:AdControl Name="photoFoodDiaryAdControlRecordPage" Width="480" Height="80" VerticalAlignment="Bottom"
            IsAutoRefreshEnabled="True" IsAutoCollapseEnabled="True" 
            ApplicationId="test_client" AdUnitId="Image480_80" />

    AdDuplex requires that the complete banner is not hidden. With this setup, if the Microsoft Advertising banner fails to get an ad the IsAutoCollapseEnable will set Visibility Collapsed showing the AdDuplex banner.

  4. Generate Ad ids

    a. In WP Dev Center publish or update. Add in-app advertising and Generate ad unit ID. 
    Add in-app advertising

    b. Sign up to Ad Duplex if you haven’t and add a new App.

    AdDuplex New app

  5. Add the required capabilities to your WMAppManifest.xml

  6. Since the ad network doesn’t always return an ad, to test your ads check for any errors occuring, and set the ApplicationId and AdUnitId to the test values from here. Simple add a break point in the method and inspect e.Error.Message if the break point is hit.

    private void AdControlRecordPage_ErrorOccurred(object sender, Microsoft.Advertising.AdErrorEventArgs e)


Now you should see the Microsoft test ad. Remember to switch you ApplicationId and AdUnitId back to what you got from the Dev Center and you are done.

Microsoft Test Ad

Technorati Tags:

Adding Localization to a Windows Phone app

If you have any Windows Phone 7 apps from the original templates, unlike the Windows Phone 8 app templates they did not come with localization setup already. So lazy me just wrote the strings inline. Fortunately adding localization after updating to Windows Phone 8 is easy.

  1. Add a Resources folder
  2. Add new Resources resx to the folder named AppResources.resx
  3. Ensure Custom Tool is set to PublicResXFileCodeGenerator
    AppResources.resx Properties
  4. Add a new class named LocalizedStrings to the root of your project
    using YourAppNamespace.Resources;
    namespace YourAppNamespace
        /// <summary>
        /// Provides access to string resources.
        /// </summary>
        public class LocalizedStrings
            private static AppResources _localizedResources = new AppResources();
            public AppResources LocalizedResources { get { return _localizedResources; } }
  5. Add an Application.Resource of your LocalizedStrings class to your App.xaml

            <local:LocalizedStrings xmlns:local="clr-namespace:YourAppNamespace" x:Key="LocalizedStrings"/>
  6. Add strings in AppResources.resx

    AppResources.resx Content

  7. Use localized strings anywhere in your Xaml

    CompanyName="{Binding Path=LocalizedResources.CompanyName, Source={StaticResource LocalizedStrings}}"
  8. To Add other languages and for more details follow How to build a localized app for Windows Phone

Don’t Develop Features, Build Designed Products

When faced with a hard deadline you are forced to make decisions fast. Below I am going to detail briefly the design decisions that took place to deliver PlaygroundCommunity for the hack::data competition.

As I stated in my last post, Developers’ Weak Spot, time and time again I fall for this trap. In PlaygroundCommunity I started all wrong. I thought, after my success of the Kindy Web Site, surely there must be a good platform for me to begin this site with. It could give me logins, forums, comments, Facebook integration etc. So began the search. I fired up the Microsoft Web Platform installer and had a look at the open source .NET based blog, forums, content management systems, to find something just right. What I found was that I had fast headed out in the wrong direction on a new project and completely wasted my time.

I did not design the product that I wanted. I had a feature ideas written down, but the problem is shopping list requirements are just plain wrong. They give the false impression that you have thought about your product when you haven’t. My motive for searching for base that had it all was that I did not want to waste anytime coding something that is already done. However, more time is wasted building the wrong thing. I started designing the product wrong. I went:

Idea > Feature Shopping List > Search for existing platform to save development time

After I waste my time, I started again. It still starts with the idea. From the idea you generally cannot help thinking of all the things the application could do. A feature shopping list. Only do this briefly. You don’t even need to write this down and can skip it completely. Coming up with features is usually easy. You need to put all that aside and think of the user experience (UX) and the work flow that is desirable for your users first. When that is taken into account, requirements that sounded good on their own, that don’t fit in the UX get dropped easily. The same goes for discovering features that fall out of the workflow that would not have been easily considered on their own. Always come from the user perspective when considering a new feature. It is like grocery shopping. You plan your meals for the week, check out the recipes and then build a shopping list based on what you need.

The solution for PlaygroundCommunity was to mock the interfaces to determine the functionality that is required. What I ended up with was 2 pages, with external services consumed with JavaScript. Nothing difficult that required a heavy, feature-filled platform to start from. Although this is very clear in hindsight, from my feature shopping list, it was not. Below are the mocks I did in PowerPoint Storyboarding, an extension for PowerPoint that comes with Visual Studio 2012.

PlaygroundCommunity Mock Page 1PlaygroundCommunity Mock Page 2

From here you can see how close the end product came. I had a few changes on the mocks after consulting a couple of people before I even started coding. It was easy to determine what could also be cut to be able to make the deadline. What makes it interesting is due to the clear scope I was then able to take a risk and use technologies I had no previous experience with, for my learning and improved user experience.

Technorati Tags:

Developers’ Weak Spot

The Internet and code sharing has made the developers who get stuck in Analysis Paralysis potentially worse. Searching the Internet for a solution to prevent reinventing the wheel (or to be diligent to ensure that you do not get it wrong) can end up wasting more time than it saves.

If there are things a good developer knows how to do, often it is worthwhile just doing them without seeing if you can get it already done. There does need to be a balance. But I would argue that the search for an existing solution should be much shorter than typically expected. I’m talking no more than 5% of the estimated time to do it from scratch, with a hard limit of a day for a really big project.

You need to make sure what you are trying to do is not supported by existing code. I remember way back at University in Java 1.3 other students trying to do manually what was provided by the framework with string.EndsWith. All they had to do was check the documentation. IntelliSense makes this much easier these days, but the frameworks, extension methods, available libraries and packages (e.g. NuGet) make the search for ‘does it already exist’ so much harder. When you do not find what you want fairly quickly, do not hesitate to abandon the search and create it yourself.

Consult the Internet, but do not lean on it so that you spend more time looking than you do doing. The Internet certainly is a great resource; we just need to make sure it is used as a resource and not as procrastinator or a crutch.

I wanted to highlight this, because in posts coming up with my development on PlaygroundCommunity I failed in this and also succeeded. It is a delicate balance.

Technorati Tags:

hack::Brisbane – PlaygroundCommunity

With the releasing of public data from Australian governments the Brisbane City Council (BCC) has done an awesome job making available a large range of data sets. To encourage the development community make good of this data BCC ran a competition, hack::Brisbane. The goal was to create anything to help improve Brisbane using this data in an app, web site or tool. The prize: $10,000. That was too big for me (and many other developers!) to ignore. Months of late nights were spent getting something done to enter.

What I came up with, was a very self-serving web site that hopefully serves many other Brisbane parents, and will work better if it does. For a little background, Brisbane has great weather; warm and sunny most the year. I have 3 young boys and we like to be outside as much as possible. Very often on a Saturday, if we have nothing on, and the weather is good, we like to go to a local playground. Brisbane has lots of brilliant playgrounds; over 1000 playgrounds. We like variety. Finding new playgrounds to try however, is more difficult than it needs to be. The BCC does have the information on its web site, but it is in lists by suburb of Parks. Of which you would need to check the details if it has a playground. As you can see below, not the nicest way to browse:

Listed Suburbs

Suburb Park Details

As you can also see, if you go to the site, there is more going on in the parks, like active parks events, exercise equipment, walking groupsreal adventure women events,  kids and teenager chill out programs, skate parksboat/canoe ramps, dog off-leash areas, bush land areas, bikeways and shared pathways, and featured parks which has a whole other list again. Each of these is displayed in a different way, lists of lists, PDF’s, RSS feeds and interactive maps. I would commonly browse the parks lists for playgrounds but with the release of the playground data, complete with Latitude and Longitude coordinates, I knew there was a better way. Welcome PlaygroundCommunity.

PlaygroundCommunity Web Site

Here’s the spiel I put on the About page:

Playground Community exposes in an easy to browse way all the wonderful playgrounds that Brisbane has on offer. It is especially useful for parents to find local or age appropriate playgrounds to visit. The playground information is able to be added to by anyone to extend the playground data in a useful way for the community benefit. It features:

• Playground descriptions, editable by anyone, which detail park and playground facilities and equipment
• 5 Star Community Rating
• Age appropriateness
• Picnic areas and Off-leash dog parks within the park
• Brisbane Active Parks live feed for community events held in the park
• Map filtering of playground features
• Community discussions for each playground
• Easy reporting issues to the council

Accessing this site on any phone with a mobile browser will give you a very different view. It is designed to be used on the road, using location services to find the top 10 nearest playgrounds, and gives minimal details to reduce mobile data usage.

PlaygroundCommunity on Windows Phone

The competition ended very successfully with 54 Entries, many very nice, submitted by 18th May 2012. For $20,000 (2 x $10,000 prizes) the council certainly got its money worth for the development done. There are now a bunch of Web Sites, iPhone, Android and Windows Phone apps promoting Brisbane and making more of it known to its residents and visitors. All the entries can be checked out on the hack::Brisbane entries page, including my entry. The winner is to be announced by 22nd June.

PlaygroundCommunity Entry

I didn’t get to include all I wanted to, as often happens with a hard deadline, but I am happy with what I did. In doing this project I took the opportunity to skill up a little on JavaScript and ASP.NET MVC. I tried out Visual Studio 11 Beta and therefore MVC 4.0 and made use of TFS Preview, Microsoft hosted TFS on Windows Azure, and SQL Server 2008 Spatial functions. All of which I intend to share my experiences with.

Publish Apps and Get a Nokia Lumia

I had been wanting to create Windows Phone apps for about 6 months now but had been continuing to put it off. When Dave Glover announced the challenge, it was the kick I needed. Publish 3 or 4 apps and receive a Nokia Lumia 710 or 800. Working almost every night, from early January, this is what I achieved:

Memory Speed

This is NOT a standard game of Memory. Once a pair is matched, it will flip back over if you do not find all the others quick enough. This game comes complete with 3 difficulty levels with up to 21 pairs to match. You must match all pairs within the Matched Pair Timeout. If a matched pair flips back over you can simply match it again, and it will be another matched pair timeout interval for that pair. If you are not quick enough, you’ll end up spending all your time rematching pairs you have already found. Game high scores and statistics are recorded to ensure you always have a goal to beat.

1 of 5 2 of 5 3 of 5

Maths Defender

There are incoming bombs falling towards the city. The only way to stop them destroying the buildings is to denote them with the code. The code is the answer to a maths equation. This game comes complete with individual operator (+, -, x, ÷) or all options, adjustable number range from 0 to 100 and 3 speed settings to challenge everyone

1 of 6 2 of 6 5 of 6

Count With Me

Keep the little ones entertained while they learn to count. Tap each object to highlight the numbers as you count. Select the right number and they objects will fly off as the count goes up. It features many different objects from robots to trees to cars and bright varying backgrounds.

1 of 6 2 of 6 6 of 6

Color Bubble

Help the kids learn their colors by popping bubbles. The player is given a colored instruction of which color bubble to pop. The bubbles then bounce around while they try and pop only the specified color. If they hit the wrong color it just bounces the bubble around more.

1 of 5 2 of 5  3 of 5

I wanted applications that would engage the brain in some way. I’ve never been interested in writing games and never done it before, but taking the approach for educational games that will be also entertaining for my three boys (3, 2 and 1/2) became very fun. I would draw the concept on the white board and then my eldest boy would watch as the development progressed and the game came to life. And he really enjoyed them.

Having developed back in 2004 for the Pocket PC I wanted to see how far the development tools had come. I thought they were really good back then and what I have found is that the experience is even more seamless. Considering I have now published 4 apps on the store without ever running them on a physical device should give a good testament to the development environment. Not to mention 4 games in a few hours a night over 2 months, never having done games development before. A far cry from my first horrible experience in 2008 in the Android Development environment. However, I assume it has progressed and would now love to port these apps over to it now.

Unfortunately, my last app was published on the 04/03/2012, two thirds through the competition and by half way through the limit of 50 entries had already been received. So I missed out on a phone. A big thank you to Dave Glover for organizing the challenge and really engaging the Australia development community. So much so that he currently has another competition running for the most download app. Unfortunately, I’m fresh out of ideas, especially ones that would appeal to the masses of Windows Phone users. Although, I still do need a Windows Phone to be able to have my boys play them whenever we are out, and they need to be distracted.