Thoughts on .Net & Coding

.Net Articles, tutorials, reviews, code and more...

  • Use $broadcast(), $emit() and $on() in AngularJS

    AngularJS applications may need to communicate across the controllers. Such a communication might be needed to send notifications or to pass data between the controllers. Although there can be different approaches to achieve this goal, one that is readily available is the event system of $scope and $rootScope. Both of these objects - $scope and $rootScope - support three methods namely $broadcast(), $emit() and $on() that facilitate event driven publisher-subscriber model for sending notifications and passing data between the controllers. In this article I will discuss how to raise events using $broadcast() and $emit() and then how to handle those events using $on().

  • Use ASP.NET MVC Controller as API

    A few months ago I wrote an article titled ASP.NET MVC Controller Vs. Web API - 5 Things You Should Know, wherein I discussed the main differences between an ASP.NET MVC controller and Web API. Some readers asked how exactly one can use an MVC controller as an API. So, in this article I am going to discuss the same with an example.

  • Prepare Yourself for ASP.NET 5 - Part 5 (Framework Versions)

    Today when you decide to develop a web application you don't need to make any decision about the underlying .NET framework. This is because there is just one .NET framework available today. Going forward, you need to give some thought about the kind of .NET framework you wish to target. Two flavors of .NET framework will be available - Full and Core. For the sake of this article, I am going to call the former as .NET Full and the later as .NET Core.

  • Prepare Yourself for ASP.NET 5 - Part 4 (Application Startup)

    In an ASP.NET when the web server (IIS) starts your application, it invokes Global.asax and code from event handlers such as Application_Start. So, things that you wish to configure when an application starts go inside Global.asax. In ASP.NET 5 the application start-up happens in a different way. This article familiarizes you with the new start-up style.

  • Prepare Yourself for ASP.NET 5 - Part 3 (Grunt, Gulp)

    Modern web applications extensively use JavaScript and CSS. While working on a project often you need to perform operations such as copying files from one folder to another, compiling Less and Sass files to plain CSS, minifying JavaScript and CSS files and more. These operations are called tasks and can be automated using tools known as task runners.

  • Prepare Yourself for ASP.NET 5 - Part 2 (NuGet, Npm, Bower)

    Any package manager basically does the job of pulling requested files from some repository and place them on your local machine. The files under consideration could be binaries (*.dll, *.exe etc.), source code files (*.js, *.cs etc.) or even documentation files (*.html, *.doc etc.). The files you receive is totally dependent on the "package" you are installing.

  • Prepare Yourself for ASP.NET 5 - Part 1 (Less and Sass)

    Some developers may find the new features of ASP.NET 5 bit difficult to grasp. This difficulty arises from the fact that they may not have worked with modern technologies such as Less, Sass, Gulp, Grunt, Bower and others. This article series is intended to give you a quick understanding of these technologies using the current version of ASP.NET MVC and Visual Studio 2013.

  • Track Number of File Downloads in ASP.NET MVC

    A common requirement in content management systems, forums and portals is to track the number of times a file has been downloaded. Such a tracking gives you an idea as to how many users downloaded a file and thus can also hint at the popularity / usefulness of the content. One can always put a hyperlink directly pointing to the file that is to be downloaded. However, such direct links don't reveal any information about the number of times a file was downloaded. Luckily, with a little bit of coding you can track file downloads in ASP.NET MVC. Let's see how.

  • Utilize Custom Events in jQuery Using on() and trigger()

    Handling client side DOM events such as click and keypress is a common task in the jQuery code. The DOM events are always bound to some or the other HTML element. However, there can be situations where you may need to flag some application specific behavior or event. Luckily, jQuery allows you to define your own events that can be raised from within your code. This article shows how jQuery's on() and trigger() methods can be used for the task just mentioned.

  • Load Views From Database in ASP.NET MVC

    ASP.NET MVC organizes view files in the Views folder. This arrangement works fine for most of the applications. However, in some cases you may need to load views from database rather than physical disk file. This article discusses how this can be accomplished.