• Using Spatial Data Types / DBGeography In Azure Worker Role

    I'd recently built some stuff that runs in Azure on a Worker role that interacts with some Spatial Data from a SQL Database via EntityFramework; having tested it locally, everything worked great. However, when published to the actual Azure environment, none of the data was being returned and my code wasn't working as expected. It turns out that the reason behind this is that in Azure you're … more

  • Planning To Use DbGeography And Points In EF: The Correct Format

    Here's a really quick gotcha if you're planning to use Entity Framework and Spatial columns with the DbGeography class support. As you're probably aware, you can't instantiate DbGeography directly, but you use methods instead, eg: DbGeography.FromText(); This method takes in WKT / Well Known Text, which is apparently a standard. A standard that I can't seem to find the definitive documentation … more

  • SQL Server Management Studio Not Presenting "Restore" -> "Database" Dialog

    I normally use a lot of backup / restore in SSMS to bring copies of production databases locally to develop or analyze, and on occasion I'd notice that doing the usual Right Click - Tasks - Restore - Database... wouldn't bring up the dialog to continue. So it turns out that this dialog doesn't actually appear unless you've previously made a backup of the database, which isn't always the case for … more

  • Running A Prerender.io Instance Locally On Your Machine

    Prerender.io is (as the name suggests) a prerendering service to allow Javascript-heavy websites and SPAs to be crawled by search engines. Recently, I've had some weird rendering issues with the pages it was caching so I wanted to do a bit of debugging. It turns out you can actually run the Prerender server locally on node.js as it's all open sourced! All it takes is a few steps, as outlined here: … more

  • MSVCP100.dll / MSVCR100.dll Missing Errors After Upgrading To Windows 10

    So, the day has arrived, the promised Windows 10 seamless upgrade and install... ...which as it turns out is not exactly a pain free process, what with Cortana being super buggy and not particularly useful (compared to the phone version), drivers being installed and messed up, and this issue, where the Visual Studio C++ Redistributables have some kind of issue. Anyway, if you get complaints … more

  • Correctly Posting String Data To A WebAPI Controller

    Seems like a pretty simple scenario, right? So I got to work and wrote the following: [HttpPost] [Route("api/users/me/delete")] public HttpResponseMessage CoolMethod(string myData) { } However, when attempting to actually call into the controller, all I was getting back was 404/not found errors. Seems strange, right? The following worked without issue, though: [HttpPost] [Route("api/users/me/ … more

  • Creating Your Own Custom Angular Maxlength Directive For Readonly Restrictions

    Here's an example - you've got a field (eg, for customer comments) where you'd like to limit the maximum number of characters entered on the frontend. Pretty simple, you just throw on ng-maxlength, right? <textarea class="form-control msd-elastic" ng-model="comments" ng-maxlength="100" name="comments"></textarea> But now, you also want … more

  • MVC Pro-Tip: Anti-Forgery Cookie Token And Form Field Token Do Not Match

    Just a really quick thing for you to check - one of the users of a MVC admin system I administer complained that they were getting this error message, after a release: System.Web.Mvc.HttpAntiForgeryException: The anti-forgery cookie token and form field token do not match. It turns out they hadn't logged out and back in again since the release - as we are hosting the website on Azure, the … more

  • Adding Multiple Messages To An Azure Service Bus Queue

    I don't know if this is a very common scenario, but I wrote some code earlier in the week to add a bunch of messages to a Service Queue: QueueClient queueClient = GetQueue(); foreach(var item in myItems) { BrokeredMessage message = new BrokeredMessage(Guid.NewGuid().ToString()); queueClient.Send(item); } This works fine for 5 messages, but it's actually kind of slow for 2000 … more

  • MVC Pro Tip: Rendering A ViewResult As HTML String Output

    Perhaps you've tried this - creating a controller, getting the ViewResult and attempting to convert it to a HTML string (for example, my use case was for an email templating / generation system). It's not terribly difficult, but there are a few caveats - primarily, that when you just "new" up a Controller outside of the proper MVC lifecycle, it doesn't have a proper ControllerContext associated … more

  • MVC Model Binding: Complex Objects and Collections

    Also known as "Why is my ViewModel returning null values to my HttpPost action?" The answer is at the very bottom if you feel like skipping straight to it. Let's say for example you have the following ViewModel and classes: public class MyViewModel { public ComplexObject MyComplexObject { get; set; } public int Value { get; set; } public IEnumerable<ComplexObject> … more

  • Enabling CORS (Cross Origin Resource Sharing) For Your Microsoft Azure Storage (Blobs, etc)

    Just a quick post about enabling CORS access for your Azure storage resources - I found most of the instructions I needed on this very helpful blog post. There's a code snippet on how to add the CORS rule to a Blob Service, but for the lazy / efficient ones, here's a little complete console app you can run: using Microsoft.WindowsAzure.Storage; using Microsoft.WindowsAzure.Storage.Shared. … more

  • Why Is Url Not The Same As RawUrl On My HttpRequest (Adventures in prerender.io)

    Merry Christmas / Happy New Year! Now that the holiday break is unfortunately over, back into the swing of things and good old hard work. Working on implementing prerender.io using the rather old (but does-the-job) MVC HttpModule on GitHub; I got it to a stage where prerender.io was working for the home page but no other pages on the site. A bit of debugging later, I noticed that the Url had … more

  • Using npm config to modify cache location, featuring a sample npmrc file

    As usual, the internet isn't always 100% up to date. Looking into the use of npm config, the documentation states that the global npmrc file lives in $PREFIX/npmrc - however, when you actually look for it, you'll find that it actually lives in $PREFIX/etc/npmrc You can find the value of $PREFIX by running: npm get config prefix On Windows, this'll be in your user's AppData folder, normally. … more

  • Azure / Microsoft Cloud: Strike Four...

    Azure has been having a string of reliability issues lately: Global VM and storage outage worldwide (with EU region being the longest affected) VSO outage We had an issue with Azure Websites and being unable to swap two deployment slots, with extremely poor support and time to resolution / SLA VSO outage, again Within a month or so, I've seen more issues on Azure since its inception. I'm not … more

  • Pro Tip: Using Node.js's child_process with Gulp and Visual Studio's Task Runner Explorer

    A quick tip - had a Gulp task set up to call Git from the command line, get the latest commit hash and append it to some html files, and while it worked on someone else's Mac, it didn't on my machine. gulp.task('tag', function(){ shell('git describe --dirty', function(err,stdout) { if(err) { throw new Error(err); } gulp.src(['index.html'], { root: base }) .pipe( … more

  • Using DTOs With Breeze.js

    Currently doing a lot of work with an existing system implemented with Breeze.js in the frontend, talking to ASP.NET MVC endpoints / EntityFramework in the back. Breeze is pretty powerful - it's a mini database sitting on the client side that just magically handles all the boring CRUD stuff for you. It's great when you're starting out and you can get off the ground super fast, but for some … more

  • How To Queue A Build For A Specific Commit With Visual Studio Online / Continuous Integration And Git

    A standard Continuous Integration build definition would usually be building the latest commit for every check-in to the master branch. But if you ever feel the need to to mess around and queue up a specific build for a specific commit, it's quite easy to do: You can simply provide the checkout override parameter either when manually queuing a new build, or in the actual build definition … more

  • Stories From The Git Frontline (or, how to revert / undo a merge that's already pushed)

    So, this happened: was working on a different branch did a merge back into master too early mistook git revert for "take me back to this point" instead of what it actually does (undo one specific commit) The tree then ended up looking like: a revert i don't actually mean to have a merge of a bunch of stuff i dont want a previous good merge before my merge the commit which i mistakenly … more