Extend Glimpse on the fly – scriptcs code execution tab in Glimpse

In scriptcs, one of the things we have been paying lots of attention to recently, is the hosting story. Scriptcs CLI is simply just one of the clients using the core scriptcs libraries - which can be used to embed the rich scriptcs code parsing and execution capabilities in any app.

This weekend I put together a small Glimpse plugin which uses scriptcs hosting, and can be used for executing arbitrary code against the context of your ASP.NET application.

More after the jump.

Dynamic per-controller HttpConfiguration in ASP.NET Web API

Recently I faced an interesting problem, where we needed to provide controllers with controller-specific configuration - but based on settings only known at runtime.

In Web API, per-controller configuration is a very useful, yet little known feature (aside from a great blog post by Mike Stall), as it allows you to create configuration profiles and assign them to specific controllers.

However it is only supported statically - through attributes, so it cannot be altered at runtime. Let’s have a look at how you might be able to hack away at it.

Adding high performance Windows Azure Cache Service to your ASP.NET Web API

Microsoft has recently announced the preview release of Windows Azure Cache Service - intended to allow you to easily deploy high performance, dedicated, distributed cache for your applications.

You can read more about the feature (and it does seem really awesome at first glance), in the thorough announcement post by Scott Guthrie.

Let’s look at how you can leverage this powerful service from ASP.NET Web API.

ASP.NET Web API 2 and HttpRequestContext

Last week (23 August) ASP.NET Web API 2 RC (release candidate) was released on Nuget. One of the interesting changes in this version is the emergence of HttpRequestContext - which provides a shortcut, strongly typed access to the information which up to this point hidden inside of Request.Properties dictionary, as well as some additional useful bits and pieces.

Let’s explore what’s under the hood.

Customizing controller discovery in ASP.NET Web API

One of the useful configuration features of ASP.NET Web API is that it allows you to be explicit about the assemblies into which it will look in order to discover controller types.

This is especially useful if you have assemblies residing outside of the bin folder, or if you are doing self hosting, and the controllers assemblies are not automatically loaded into the current AppDomain.

There are several hooks in the pipeline that you can plug into to achieve this goal. Let’s explore them, discussing the pros and cons of using any of these.

Message handlers scoped per route in ASP.NET Web API

A lot of Web API functionalities are based around message handlers. The real power of them is that they run for every request and provide an easy mechanism of globally addressing some of the application concerns (such as i.e. security). However, there are situations where you’d like to use a handler to apply specific behavior to only a selected portion of an application.

Let’s have a look at how you’d do it with route-specific message handlers

Owin middleware, ASP.NET Web API and client’s IP address

Not so long ago, we discussed on this blog the possible ways of retrieving the client’s IP address in ASP.NET Web API.

With the latest changes in the Web API 2 infrastructure, and the emergence of Owin and the Katana project as the common glue between the underlying host and the web framework(s) running on it, it’s becoming natural to move these types of application-wide concerns (security, logging etc) to Owin middleware.

Let’s have a look at how you could - as an introductory example - obtain client’s IP address at the Owin middleware level, and why is it beneficial.

Scriptcs and multiline REPL!

A while ago, we added a killer REPL feature to the scriptcs project. Recently, we followed it up with adding support for one of the most popular requested features - multiline constructs for the REPL.

It’s not yet available in the stable version available via Chocolatey or on the master branch on Github, but you can get a taste of how it looks and feels by installing the nightly build or building from dev branch directly.

Let’s have a quick look together.

Building Spotify remote control service with ASP.NET Web API and SignalR

I have just published a new article over at my friends from Tech.pro (who have revamped their site this week too, and it looks awesome!). It’s my third one there, and once again we look at utilizing ASP.NET Web API, SignalR and bits of Knockout.JS. This time, however, it’s all single-user, as we will try to create a service that would allow you to remote control your Spotify client over HTTP.

IHttpActionResult – new way of creating responses in ASP.NET Web API 2

In the first version of Web API, you had two ways of creating response from an API action. Either return a specific object instance (or void) and let the Web API pipeline convert that to an HttpResponseMessage for you, or return a raw HttpResponseMessage. In that case, you had to construct it manually, and you bypassed all of the internal Web API mechanisms (formatters, content negotiation).

Now in Web API 2 (which was just released in beta) we get a third option, which is IHttpActionResult. It’s very simple, yet extremely powerful - so let’s explore it in this blog post.

About


Hi! I'm Filip W., a software architect from Zürich 🇨🇭. I like Toronto Maple Leafs 🇨🇦, Rancid and quantum computing. Oh, and I love the Lowlands 🏴󠁧󠁢󠁳󠁣󠁴󠁿.

You can find me on Github, on Mastodon and on Bluesky.

My Introduction to Quantum Computing with Q# and QDK book
Microsoft MVP