Skip to main content


Processing ASP MVC Web API Requests in Multi-threaded JS Web Worker

Unlike an asynchronous Ajax call, HTML5 Web workers provide an opportunity to run a Multi-threaded JavaScript code in modern browsers that support them . Each worker spawns an isolated thread with dedicated JavaScript Event Loop, Stack and Heap memory. For example a regular Ajax Call to MVC Web API service call goes through the following asynchronous call cycle. The JavaScript Event Loop in this case could be interrupted by events that are being executed on the UI; for instance, a "window.alert", could possibly stop all scripts on the page from executing until a user responds. Replacing the Ajax Call with HTML5 web worker provides a great way to run long running scripts in separate threads so that asynchronous code execution is not interrupted by UI events. Here is the a JavaScript worker implementation of the same MVC Web API call using a JavaScript web worker. Despite the advantages of using a web worker, implementing one requires working with some constr
Recent posts

Simple and reusable directive for making list elements draggable.

I was working on Angular lists and needed a easy to implement and reusable solution to make list items draggable . I chose to implement the solution as an Angular directive so that I can pass scope references to the new helper controller and execute ng-repeat, as needed, to recreate Dom elements. After adding the helper controller, I was able to make ng-repeat lists in my application draggable by simply adding a custom attribute and passing the Angular collection name. Here is a Plunkr demo  and full GitHub source code .

ASP.MVC Real-time data processing with Sharded RavenDB and SignalR

In a move that some call "Radical” The Weather Channel recently swapped their enterprise Oracle and MySql Databases for NoSQL  MongoDB .  One word that could describe the rapid adoption of NoSQL databases compared to relational once is “ sharding .” Unlike relational databases, NoSQL systems allow developers to be active participants in the data storage process by providing a way to create logic (sharding strategy) that outlines how and where data could be stored, resulting in better scalability and improved performance. RavenDB , an open source NoSQL system for .NET that is easy to deploy (both as a standalone/embedded system) for an ASP.MVC application. SingalR is a tool that one can use in a .NET environment to add real-time client-server processing in an application. SignalR allows a developer to broadcast messages to all (or some) clients from a centralized client and/or server call. I was looking for a quick data-sharding example with embedded RavenDB that I can

Miniprofiler and QUnit in ASP.MVC

Miniprofiler and QUnit are simple DLL, JS and CSS files that can be added to an ASP.MVC project to identify trouble spots in a project such as server side functions that run longer than anticipated or intermittent JS errors/warnings that show up in browsers' consoles. Miniprofiler - keeps track of the amount of time functions in an ASP.MVC source code take to execute and displays the results on a browser. I have found that functions that take longer to execute are good candidates for refactoring. To add Miniprofiler: Use Package Manager to add references to Miniprofiler in your project PM> Install-Package MiniProfiler Update Global.asax file as follows (this is for making the library available globally in your project) using StackExchange.Profiling; and protected void Application_BeginRequest() { if (Request.IsLocal) { MiniProfiler.Start(); } } protected void Application_EndRequest() { MiniProfiler.Stop(); } Add the following one li

From your ASP App to the Compiler with Compilation Directives

If you have some code that you want to run locally for testing, you can check current "Request" and look at methods like "Request.IsLocal" to conditionally include test modules. However, there are times you need to bypass the ASP.NET application life cycle and directly exclude or include a source code from compiling using compilation directives. Here is an example of a use case where you might need to bypass the application life cycle in order to run code during development. Consider a case where you need to include some JS and CSS styles, say, you have QUnit   files stashed somewhere in a folder of your app, during development. If you are working on an ASP.NET page, view or controller you can access incoming HTTP Request by using: var currentRequest = Request; or if you are accessing the "Request" object from a class that does not inherit from "Page" in ASP.NET or "ViewPage" in MVC (or any other object that has the current

Upgrading from Angular 1.0 to 1.2

One of the projects I recently worked on required an upgrade from Angular 1.0 to 1.2.  The upgrade was not a result of Angular 1.0 limitations (in terms business needs), version 1.0 works just fine; however, Angular 1.0 is an experimental release and chances of running into already known and less desirable issues was very likely without moving to a stable version of Angular. Here are the steps that I took to rewrite the application JS functions to work with Angular 1.2. Caveat:  Folks at Angular have migration guideline documentation here -  - the steps I outlined below only deal with updates to a specific application (Angular 1.0 running with WCF web services), you might want to review the migration guideline document if you run into any issues after your application upgrade. Steps Take the plunge  – remove references to Angular 1.0 and replace them with Angular 1.2. You will need two JS references for Angular instead of one. < sc

Pseduo-RegEx JQuery Selectors

More often than not I find myself using only few jQuery selectors to locate elements in DOM for event binding; however, jQuery also offers some powerful psedo-RegEx selectors for locating elements. Say, you have the following HTML5 markup: -------------------------------------------------- <!DOCTYPE HTML> < html lang = "en" > < head > < meta charset = "UTF-8" > < title > JQuery Selector </ title > </ head > < body > < article class = "post-article" > < header class = "article-header" > </ header > < p class = "article-content" > </ p > </ article > </ body > </ html > -------------------------------------------------- You can use the following selectors to locate the "article-header" element. 1- Using closest     $(".post-article").closest("header").fi