Programming Seeking Understanding
The blog of Mark Cheeseman

Webforms and Gulp

Recently at work we have been moving our front end development over to newer technologies. This was motivated by a number of factors.

We were looking for a solution that

It was decided the way forward was to use Gulp for processing the javascript development pipeline, and Karma for running javascript tests. Putting all this into an existing ASP.NET Webforms application presented a few little hurdles. A sample application with the major features of how it all hangs together can be found here.

Adding karma testing was relatively easy. Using Gulp for the javascript development pipeline posed a few more issues. The majority of these revolve around the fact that there are essentially two independent compilation processes, msbuild for the C# server side, and gulp for the javascript. Where previously these two sides were intertwined through the Telerik ScriptManager, now they are completely independent. Their independence makes front-end development easier and quicker, but of course, at some point they must come together. The critical point for this is where a page requests a javascript file. Our particular solution to this can be seen in the way MyCacheBustedpage.aspx uses the CacheBuster class to request the current merged, minified, cache-busted javascript file, which was produced by the gulp pipeline.

The end result of this work has largely been positive. Front-end development is generally easier, faster, with quicker feedback cycles whether working with javascript unit tests or viewing pages. Javascript development with Karma tests does not necessarily require Visual Studio at all. When developing and viewing pages Visual Studio may be running to serve up the pages with useful data, but the development environment itself can be anything (I frequently use vim), and gulp compilation on save is only a second or two long.