Blog posts page 4 of 44

Comma-separated parameter values in WebAPI

The model binding mechanism in ASP.NET is pretty slick — it’s highly extensible and built on TypeDescriptorTypeDescriptor for re-use that lets you avoid writing boilerplate code to map between CLR objects and their web representations.

One surprise, however, is that out of the box, neither WebAPI nor MVC support comma-separated parameter values when bound to an array, e.g.

Model binding form posts to immutable objects

  • đź“…
  • đź“ť 633
  • đź•™ 3
  • 📦 .NET
  • đź’¬ 2

I’ve been working on porting over my blog to a static site generator. I fired up an Azure Function to handle the form-comment to PR process to enable user comments to still be part of the site without using a 3rd party commenting system — more on that in the next post — and found the ASP.NET model binding for form posts distinctly lacking.

It’s been great getting back into .NET and brushing up some skills making the code clear, short and reusable. What I wanted was a super-clear action on my controller that tried to collect, validate and sanitize the data then, if all was well, create the pull request or report errors.

Differences between Azure Functions v1 and v2 in C#

  • đź“…
  • đź“ť 618
  • đź•™ 3
  • 📦 .NET
  • đź’¬ 2

I’ve been messing around in the .NET ecosystem again, jumping back in with Azure Functions (similar to AWS Lambda) to get my blog onto 99% static hosting. I immediately ran into the API changes between v1 and v2 (currently in beta).

These changes are because v1 was based around .NET 4.6 using WebAPI 2 while v2 is based on ASP.NET Core which uses MVC 6. There are some guides around conversion, but none in the context of Azure Functions.

Download files with progress in Electron via window.fetch

Working on Atom lately, I need to be able to download files to disk. We have ways to achieve this, but they do not show the download progress. This leads to confusion and sometimes frustration on larger downloads such as updates or large packages.

There are many npm libraries out there, but they either don’t expose a progress indicator, or they bypass Chrome (thus not using proxy settings, caching and network inspector) by using Node directly.

Monitoring URLs for free with Google Cloud Monitor

As somebody who runs a few sites, I like to keep an eye on them and make sure they’re up and responding correctly.

My go-to for years has been Pingdom, but this year they gutted their free service (update 2021 it’s toally killed and now owned by Solarwinds… yeah, the people who got hacked and unknowingly distributed a back door to all their customers) so maybe not that service.

Notes on Edward Tufte’s Presenting Data and Information

Here are my notes from today’s event by renowned statistician Edward Tufte — author of The Visual Display of Quantitative Information and Envisaging Information primarily for my own reference but perhaps of interest to others.

No announcement, no preamble. The lights went out, and a visually striking video showing a representation of music started. Conversations were immediately hushed, and devices put away. An effective technique to get attention and signal an absolute start.

Time window events with Apache Spark Streaming

If you’re working with Spark Streaming, you might run into an interesting problem if you want to output an event based on multiple messages within a specific time period.

For example, I want to send a security alert if I see 10 DDOS attempts to an IP address in a five-minute window.

Table per hierarchy in Azure Table Storage

  • đź“…
  • đź“ť 590
  • đź•™ 3
  • 📦 .NET

If you’re coming from an ORM background to Azure Table Storage, you might be wondering how to map class hierarchies to tables.

Documentation on the topic is hard to find unless you know the magic class name EntityResolver which you can discover by digging into the Azure Client for .NET source code.