Let me set the stage for this post first. Peergroups.be, the sharing economy website I develop for the non-profit WijDelen, is based on ASP.NET MVC. So I have a bunch of Controller classes with methods that end with return View(model);. Our first goal was to have a web application running as quickly as possible. Now that we have a stable system with active users, we’re looking into writing a mobile app. The mobile app can have the same pages/screens as

I’m currently working on a NodeJS project that makes HTTP calls to an ASP.NET (4.5.1) application. When running locally, I also want to make these calls to my local ASP.NET application. Sometimes, however, I don’t want to start up Visual Studio, open the project, compile, and run. Seeing as this is not ASP.NET Core, I can’t just run it from the command-line. Or can I? It turns out that if you have IIS Express installed (which you should have, with

Have an old(er) ASP.NET project where javascript files put all their functions and variables in the global namespace? Want to move to modern javascript (ES2015) with dynamic module loading? If you don’t know where to begin, this guide might be able to help you. I was facing the same issue in an ASP.NET project (MVC, but it should be possible for WebForms too). It’s actually quite simple. We’ll go from this: Browser loads a page Browser loads all included javascript

I’ve recently been adding Knockout to an ASP.NET MVC application. I would consider Knockout a previous-generation solution and would prefer to use a full-fledged SPA framework like Aurelia, but that’s a bit out of scope for the moment. After introducing Knockout, I wanted to add unit tests on my viewmodels with Mocha. I had some trouble at first, and read quite some answers on StackOverflow that claimed you need a browser. Because you’d want to run the tests from a

In one of my previous posts on Aurelia, I set up Aurelia with ASP.NET, using jspm to load my scripts, and Babel to transpile the ES2015/2016 (previously called ES6/7) to ES5. The problem is, this happens on-the-fly. This will reduce the speed of our app, as there is extra processing done when the user requests a page. Also, there is no reason to do this, as the scripts can be transpiled before deploying (i.e. when building our app in Visual

Aurelia is a great framework for a SPA, but one thing that is missing, I feel, is getting server-generated templates. By default, Aurelia uses the moduleId to fetch a static HTML file. Take this configuration: router.configure(config => { config.map([ { route: [”,’Welcome’], moduleId: ‘./welcome’ }, { route: [‘About’], moduleId: ‘./about } ]); }); When you navigate to #About, two calls will be made: http://www.example.com/about.html http://www.example.com/about.js If your view is at some other location, you can customize the ConventionalViewStrategy.convertModuleIdToViewUrl function: ConventionalViewStrategy.convertModuleIdToViewUrl

A small post for my own reference, and yours if you need it. It took me a while to get this working. In ASP.NET 5, the WebAPI Controller is no longer the same as the WebAPI 2 Controllers we’re used to. These Controllers are quite specific on how they accept content. Aurelia has an easy way of posting to a Controller: import {HttpClient} from ‘aurelia-http-client’ @inject(HttpClient) export class MyViewModel { constructor(http) { this.http = http; } callService() { this.http.post(‘http://some/url’, {

Aurelia is Rob Eisenberg’s new framework for SPA’s (single page applications), and I wanted to set it up in combination with ASP.NET. I’m a fan of Angular, but I’ve been watching Aurelia closely too. Angular has a large following, which I find very important, because it guarantees you will have quick and easy support when you encounter a problem. But I dabbled with Durandal and like Rob Eisenberg’s approach. It feels like there has gone a little more thought into

In my previous post, I outlined how to use ASP.NET MVC and Angular together, making certain views pure MVC and others Angular. When I first used Angular this way, I was so happy, I went the full Angular way making requests from Angular for my data. Essentially, something like this: $http({ method: ‘GET’, url: ‘/api/rest/’ }) .success(function (data, status, headers, config) { vm.names = data; }) .error(function (data, status, headers, config) {}); This is code inside my customers.js. It’s just

Angular is a great tool, but it took me some time to find a way to combine it elegantly with ASP.NET MVC. This is basically how I did it. First, create a new ASP.NET MVC application. Next, install the Angular package via NuGet. Now for the customization. The objective is to use the normal ASP.NET MVC navigation, unless for certain URLs, when we’ll let Angular take over. So http://www.example.com/Account/Login would be handled by ASP.NET (“ASP.NET-mode”), but http://www.example.com/#/Customers would be handled