ClosedXML is a .NET library for reading, manipulating and writing Excel files. ClosedXML is a fine library for exporting data to Excel. It is very simple to use and fast enough for smaller sets of data. Firstly you have to add reference to ClosedXML. Install ClosedXML using NuGet Package Manager. Using ClosedXML you can set … Continue reading Export Collection of data to Excel in c# using Closed XML
Mock HttpContext using moq Framework
Moq is a framework that allows us to simulate dependencies at test time and monitor how our system under test interacts with them under various circumstances. Mock objects allow you to mimic the behavior of classes and interfaces, letting the code in the test interact with them as if they were real. In a project … Continue reading Mock HttpContext using moq Framework
Unit Tests for .NET MVC Controller
The goal of this post is to demonstrate how you can write unit tests for the controllers in your ASP.NET MVC applications. A controller unit test should test the code algorithms in your action methods, not the behavior of its dependencies (data layer logic). Step 1 : Create a new MVC project and Add Microsoft unit test … Continue reading Unit Tests for .NET MVC Controller
Parallel.ForEach() Vs Foreach() Loop in C#
Foreach Loop Foreach loop runs upon a single thread and processing takes place sequentially one by one. Foreach loop is a basic feature of C#. Its execution is slower than Parallel.Foreach in most of the cases. Syntax foreach( var item in list){ DoFunction(item); } The problem with this foreach is that item 1000 has to wait until … Continue reading Parallel.ForEach() Vs Foreach() Loop in C#
SignalR: Call client methods from Custom ActionFilter class and Publish messages (Render MVC View as a string) to all subscribed clients
Sometimes we would like to perform certain action before or after a particular operation, or some times we need a pre or post action behaviors from action, for achieving this functionality ASP.NET MVC provides a feature called Filters. Action filters are used to implement the logic that get executed before or after a controller action executes. … Continue reading SignalR: Call client methods from Custom ActionFilter class and Publish messages (Render MVC View as a string) to all subscribed clients
Convert .xls file to .xlsx in c#
Recently, I faced one issue while handling excel file in c#. I was developing an application which read data from an excel file. but when I try to open it, an exception was thrown if the source file is saved with the .xls format. The exception messages is that "File contains corrupted data error when opening … Continue reading Convert .xls file to .xlsx in c#
Introduction to AngularJS
AngularJS is a client-side JavaScript MVC (Model-View-Controller) Framework meant for implementing Single Page Architecture (SPA), maintained by Google. It helps to build web applications. Core Features Following are most important core features of AngularJS − Data-binding − It is the automatic synchronization of data between model and view components. Scope − These are objects that refer … Continue reading Introduction to AngularJS
Website in Maintenance Mode Using IIS
Usually, there is a scenario when we upgrade our production site to a new release, we want the users to be redirected to the “Down for Maintenance” page. IIS provides multiple ways to cut access to an application. We can allow\deny access to a website based on IPv4 address or its range or domain name. … Continue reading Website in Maintenance Mode Using IIS
Coding standards and Naming conventions
This post will helps you to understand basic coding conventions. A consistent naming pattern is one of the most important elements of predictability and discover-ability in a managed class library. Purposes of coding conventions They create a consistent look to the code, so that readers can focus on content, not layout. They enable readers to … Continue reading Coding standards and Naming conventions
NLog
NLog is a free logging platform for .NET, NETSTANDARD, Xamarin, Silverlight and Windows Phone with rich log routing and management capabilities. NLog makes it easy to produce and manage high-quality logs for your application regardless of its size or complexity. NLog is an open source library distributed at no cost under the terms of the … Continue reading NLog