Blog Posts

Migrating a Unifi controller in place onto UDM SE
Mini project goal To replace my current gateway (Ubiquiti, but not Unifi) and Unifi controller with a UDM SE for a more integrated Unifi experience, being able to easily segregate my vlans, wlans, setup firewall rules, etc from a single interface. While keeping the settings and adopted devices that I...
Handling permissions for Azure resource's Managed Identity
Actual real life problem I’m using System Assigned Managed Identities for some of my App Services in order to not handle credentials manually in code, and also to make sure that the life cycle of the Service Principal (a managed identity is a Service Principal) matches that of the App...
Microsoft exam AZ-900 vs AZ-204, which one is right for me?
So you’re interested in taking either/or both the AZ-900 and the AZ-204 exams in order to become Microsoft certified as a Azure Fundamentals or Azure Developer Associate. That’s great! Perhaps you’re starting your journey towards a cloud oriented role, want to make sure that you don’t have gaps in your...
Generate Swagger file to disk with Swashbuckle in DevOps
Actual real life problem We’ve got a .NET core project with a web API, and we’re using Swashbuckle to generate Swagger Open API documentation for it. Now we want to integrate this into our API Management instance, using a custom DevOps task (not important for this post) which requires us...
Structured logging with Durable Functions and Application Insights
There’s a big difference between logging for debugging/development purposes and for monitoring your application. When developing it’s quite easy to write a line containing something similar to this log.LogInformation($"The code reached this function with id {id}"). And this is valuable when debugging the code, but when you’ve deployed it and...
Easy github pages index.html
Preamble This came about when I asked myself the question “What would be the easiest/quickest way for me to get a company webpage up in order to satisfy Apple’s requirement for registering as a developer”. I already have this blog hosted on Github pages (Source code), and although this setup...
Define security schemas for Swagger UI to try out authenticated endpoints
You’ve got an API, it’s secured by OAuth using the Client Credentials flow (typically used for server to server communication), and now you want to enable the consumers of your API to try it out in an authenticated way, directly from Swagger. This post is about an API that uses...
Secure your Swagger endpoints using basic authentication
What are we trying to do? We’re trying to lock down our Swagger endpoints (index.html, swagger.json) in order to disallow unauthenticated users from reading our documentation. Why would I want to do this? Perhaps you’re building a internal API, or an API that should only be available to a few...
Singleton orchestrators in Durable Functions
The Durable Functions documentation describes one way of doing this, this does however not fit every use case where you might need to run a orchestrator function as a singleton. Actual real life problem I’ve got an orchestrator that triggers every 5 minutes, however, at times the execution of this...
Shared variables in docker-compose.yml
This post started out as me trying to solve a fairly straight forward problem (stated below), but instead fell into the rabbit hole of YAML structure and concepts. Problem I’ve got a docker-compose setup for running an app locally, it consists of one database service, and one api service. It...
Using MS SQL Server with Python and docker: MS SQL default database in docker
Problem This is a continuation on This blogpost. But now we’ve come to the step we’re I want to add a default database when the container starts for my application to connect to. When doing this with .NET Core there’s an option for creating a database if it doesn’t exist,...
Using MS SQL Server with Python and docker: MS SQL in docker compose
Problem I’m currently in a team that’s developing an app with a python backend, that’s deployed to Azure with a MS SQL Server as a database, but uses a SQLite database for local development. This creates issues with having different capabilities and slightly different syntax/rules/keywords. One good thing is that...
C# and JS to python: Scoping in Python
Problem I have a function that should trigger a callback, lambda, Func, Action (or any other name that your language of choice might use for this concept). I also want to write a test to make sure that my function trigger this callback under certain conditions. The least invasive way...
Variance with generic classes and interfaces in c# (type matching, type guarding)
Actual real life problem I’ve got a .NET (framework) MVC application (using EpiServer) where most (but not all) views are typed to a Model of type PageViewModel<T> where T: PageData. The feature to be implemented is to render a property of PageData whenever we’re rendering a view that’s typed to...
Accept tokens from multiple identity providers in .NET Core
There’s at least 2 ways of interpreting the title of this post, it could mean: As an API, accept tokens coming from multiple applications that use different identity providers. As an application, allow a user to sign in using multiple 3rd party identity providers, and optionally act as an identity...
Deploying to azure using Github and Visual studio Team services
Currently I have a decently small project that consists of a React SPA that’s built using webpack, the SPA communicates with a api that’s built on .NET Core (2). The code for these 2 units lives in the same repo on Github and they are built on, and deployed to...
Xamarin UserControl instantiation and binding context
Having worked with React for the last 3 years has made Components my favourite way of structuring code, it might have been 5-7 years since I worked with WPF and Silverlight but I do remember them having UserControls as a concept which is fairly similar to Components. This term doesn’t...
IdentityServer4 with Azure KeyVault
So you’re using IdentityServer4 in your .NET Core application that you’d also like to deploy to Azure. You’ve been using .AddDeveloperSigningCredential() to create keys for signing your tokens and you’ve figured out that this is no good in a production environment. Maybe you’ve been thinking about generating a certificate yourself...
Conclusions of a React Native hackalong, abridged
I was recently asked to hold a React Native hackalong with the not so secret agenda of finding out if React Native was a good alternative for quickly prototyping native applications, if it was viable for production applications, and how fast a web/React developer could get up to speed with...
How to run NPM scripts (or do other stuff) when deploying to azure from github
How to modify the deployment process of microsoft azure is one of those things that I keep forgetting how to do, or find myself making more complicated than it has to be. This post assumes that you’re deploying with continuous deployment from github, but it should be the same for...
Validate authorization policy in MVC6 vnext, asp.net5
###Background Asp.net vnext now supports creating authorization policies through code. What this means is that you no longer have to copy paste your role/claim names all over your application (Or build your own system around this). You can instead declare policies in a central place and authorize based on these,...
Global Authorization attribute filter in MVC6 vnext, asp.net5
Or “Where did RegisterGlobalFilters go”. You might have read Securing your ASP.NET MVC 4 App and the new AllowAnonymous Attribute or similar posts about adding a global [Authorize] attribute to your MVC project and then whitelist specific routes such as login pages. The code for this would look like this:...
Custom cultures and multi-tenant localizations in .net
I’m currently converting a webapplication into a multi-tenant solution for a client at work. Handling translations in the app is currently done using resource (.resx) files to build a master resource collection. The client can then translate any resource into a specific language using a separate tool that creates satellite...
Javascript objects are hashmaps, how to clone and/or merge them
I love javascript, I really do. One of the things i really enjoy about the language is its dynamic nature where objects are actually hashmaps, associate arrays, dictionaries, or whatever you want to call it. This gives us the ability to get and assign properties using indexing and property names...
Augmentation factory pattern
The augmentation factory pattern is an extension of the normal factory pattern when working with dynamic languages. It can be thought of as a way to get interfaces into javascript, or a way to deal with inheritance without using any actual inheritance. I do not find it helpful when working...
Things you might forget how to do in sql (server)
My goal has always been to be a “full stack developer” and this is also something that is required of me in my current position. But there used to be a time when a spent most of my energy on the top layers of application, ie UX, APIs and business...
CSS boolean states using hidden checkboxes and radios
I recently came across CSSSlider, a tool for creating pure css sliders/carousels, no javascript required at all. I really didn’t get how they had done it at first, since I’d never thought of the approach that they took. I took a look at the source code and saw a lot...
Perfect height-width ratio in fluid css layouts
I wrote Tily, a css framework for creating fluid, perfect ratio windows8/windowsphone style tiles in web applications about a year and a half ago. It’s taken this long for me to write this post explaining how it works, but hey, here it is. Most web developers have probably at some...
Compact datatransfer experiment
I create a lot of different APIs in my work, several of them send out fairly large arrays of objects where the property names of these objects are the bulk of the data being transfered. This is mostly mitigated by compressing the data, but I figured, why not try and...
Whitespace in HTML matters
Inline elements in html are elements that flow in the documents direction (ltr/rtl) until they hit the edge, and then they line break, just as text in a book or a newspaper. When rendering such elements (spans or display: inline,inline-block etc) the browser will treat the whitespace between them as...
Json.NET is awesome
99% of the work that I do involve asp.net webapi and asp.net mvc in some way, I normally build applications using knockoutJS on the frontend and asp.net webapi as, well, a web api. Json.NET is the default javascript/json handling library in asp.net mvc and webapi. It normally perform its magic...
Repurpose, rename ASP.NET solution and projects
Exciting times as Stratiteq, I’ve gotten my first “new” application where I will be tech lead. It’s an application built for a specific part of the customers service offerings, but it turns out that it would be perfect for other services that the customer offers. The teams job will be...
Automate and livereload a jekyll site with less using grunt
I’ll be the first to admit it, my “workflow” is/was really ancient, my professional work is to 99% done in Visual Studio which has made me a bit spoiled since it handles almost anything you want it to do. Work that I do for fun on the other hand is...
Relationship of jQuery data and data- html attributes
I have noticed a pretty common confusion about what the jquery data function and HTML data- attributes are meant to do amongst developers that are new to building frontend bits. This can also be confusing for developers that got into jQuery before 1.4.3 (like me) as the data function was...
Transactional repository pattern
Why a new pattern? I should probably begin by saying that I have no idea if there is any prior art for this, this is something that I just came up with while building the back-end for a new application. It is meant to simplify making a sequence of repository...
Extend Dapper Dynamic Parameters to send Table Valued Parameter to SQL Server
So you want to pass a list of something to a SQL stored procedure/Query using Dapper? And you want to receive it as a Table Valued Parameter? Sounds great, you might feel a little bummed that this isn’t supported out of the box in Dapper, meaning that you can’t simply...
Structuring less for multi-site projects
We sometimes find ourselves in the position that we have a single project that exposes several sites, most commonly a large brand with several smaller brands in the same corporation. This is yet another way in which LESS shines in comparission to writing plain old CSS. What we can do...
Calisthenics isn't like weightlifting
So today is my first day of summer vacation and I thought that would be a good date to write a post about my progress with my calisthenics goal. First thought, Calisthenics isn’t like lifting weights. Lifting weights has been pretty much the single form of excercise (besides some regular...
Fiddler doesn't show WebClient request inside of MVC action on IIS
I pretty much always run my .NET applications on a local IIS server instead of using Visual Studios built in server, I also use the local IIS for debugging. The reasons for doing this is part performance, part not racking up VS debug server instances and part wanting to run...
Anatomy of a web UI framework, Part1: the grid
After a year of thoughts and a few projects regarding modern UI in web applications I now feel that I’ve got enough material to assemble a new web framework. There might be a few other ones out there trying to accomplish the same task, but I feel that most of...
First day of calisthenics
New goals in the field of fitness. I want to be able to to planche pushups and the human flag. This of course requires me to change my normal bodybuilding style regiment and include some form of calisthenic movements. I’m currently in the stage where I need to work on...
Installing Jekyll on Windows
Use Ror 1.9 for painless installation. http://railsinstaller.org/en Python 2.7.5 for Pygments. setx path “%path%;c:\Python27”. Restart console Don’t forget to set HOME PATH if it’s currently set to a network drive. SET HOME=%USERPROFILE% gem install jekyll gem install pygments.rb. Only use 0.5.0 as of writing http://stackoverflow.com/questions/17364028/jekyll-on-windows-pygments-not-working
url.action and outbound url matching using current request parameters
Say that you have a pretty standard app with the /home/index/id routing. You have a page with the following route /home/index/1 and on this page you want a link back to /home/index so you use @Url.Action("index,"home") to generate the correct link. But you notice that the generated link have the...
dont check for case sensitive request headers in your serverside code
Todays funny bug, no ajax request would return data in a real IE8 (not effecting ie10 in ie8 mode). We’re building a MVC4 + WebApi app and are heavy users of ajax that we setup using $.ajaxSetup and setting custom AuthToken and AuthTokenSalt headers in the beforeSend function. Everything works...
html.action and url.action
Some headache last night just before going to bed. I was trying to output two Uris to data attributes on a html element for navigating to different pages based on the current state of the page. I was getting weird crashes and the debugger kept hitting an action that I...
sql server between is not zero based
A small gotcha that happened a colleague tody. A simple search for paginated content went wrong. The first page searched for items BETWEEN 0 and 10 and the second page searched for items BETWEEN 10 and 20, the first page looked alright but the first item on the second page...
dension gw 500s bt in porsche 997
Whats the first thing you do when you buy a new car? Upgrade the stereo to support A2DP phones of course The PCM 2.1 system found in my car only supports two ways of playing your own music, using a cd or a fm transmitter. Neither of thos really speaks...
Dont add duplicate mime-types to an iis site
It is for some reason possible to add duplicate mime-types through inheritance to a site running on IIS. Doing this will cause 500 server error for statically served files. My issue was with running virtual directory sites and adding a mime-type to the default site itself. The solution was to...
Limitation in Sitecore Multilist field
There seems to be a limitation on visible items in a multilist field when settings the source as a sitecore node such as /sitecore/content/mysite. I didn’t count but it seems to “only” show the first 50 subitems. A solution for this is to instead use a sitecore query as the...
datetime from unix timestamps
C# Ticks are not the same as Unix Timestamps. Ticks are instead 1/10.000 of a millisecond. This means that we of course cannot just do new DateTime(long ticks); //with the TimeStamp as ticks Instead we have to do it like this. new DateTime(1970,1,1,0,0,0,0).AddSeconds(double ourTimeStamp) Which is actually kind of pretty....
RedirectToAction and the ViewBag
This should have been fairly obvious, but we cannot expect the ViewBag to persist since a RedirectToAction only serves the client with a 302 redirected HTTP response to the new route. A solution for this is to use “TempData[“key”]”, this is a dictionary that is persisted in the users session...
Object literal as property on a prototype object results can cause headaches
Part of today was to enable an object literal to be used as a prototype. This object in turn had an object literal of its own (along with a few methods). Here is pseudo-code to display what happened: The object to be used as a prototype baseObject = { settings:...
Less !IMPORTANT mixins
I thought I should share this even though I’m generally against using !important in css rules. Less will place an !important rule after every rule in a mixin if you write !important after the mixin name when you mix it in. This seems logical but it was something that I...
ios web-clips pin webapp to homescreen
Guides for creating icons that are used when pinning a website to the iphone/ipad homescreen. Apple documentation
Manually removing ContentTypes from Orchard can be tricky.
I was experimenting with a new contentpart widget tonight, and when I was done I had a couple of UpdateFromX methods in my migrations.cs file. So I thought to myself, this doesn’t look very good, lets delete everything from the DB and then combine this to a pretty Create method...
Download file / image instead of displaying it in browser
New day new requirements. Atleast this was an easy one. The normal action when clicking an anchor tag with an href pointing to an image is to display the image in the browser. Today this was not the desired outcome, instead I wanted to put an “Download image” button next...
Removing zone div wrapper in Orchard
If you have ever tried building a new Orchard theme from scratch, and like me you like full control of your markup. Then perhaps you have noticed the extra “zone-name” div that Orchard adds around every zone. This is great for creating a semantic markup, but it didn’t suit my...
Change the framework for an application on IIS6
Sometimes you have to work with older software, like IIS6 on windows server 2003. And sometimes this happen to coincide with you working on an application that requires an older framework, like Sitecore 6.1 on .NET2.0 I was trying to run a Sitecore 6.1 site in IIS6 on a windows...
XSLT rendering with sc:image in for-each
It was a real easy task. Display the ImageField and GeneralLinkField for every item that was selected in a MultiListField. So I took a look at the code, crap, it’s XSLT and I’m mostly a .NET guy who never touches the stuff. It wasn’t easy to find a clear answer...