Latest posts on category "Technology"


Delegates and Events in C#

Delegates and Events in C# .NET. Simple example, self explainatory code with comments inline. Lets check it out in code behind.



The repository and unit of work patterns are used to create an abstract layer between data access layer 

and the business logic layer. This can help to insulate application from changes in data store and also help in test-driven-development (TDD).

In this post, I have implemented a repository class for entity type "User" creating a repository interface and a repository class.

When we instatiate the repository in the controller, the interface will accept a reference to the object that implements the repository interface.

1. When the controller runs under web server, it receives a repository that works the Entity Framework.

2. When the controller runs under a unit test class, it receives a repository that works with either in-memory data or a mocking database which can be easily manipulated for testing.

The unit of work class wraps the work of multiple repositories by creating a single database context class shared by all.


While one of my web service was running on local IIS express, everythiing was working fine, but then I was supposed to provide cross platform team to hit the servive locally in debug mode so that they find the exact reason of error.  For that I tried to change IIS express to local IIS. After making changes I noticed that it started yelling Bad Request 400. Lets see who to resolve this problem as its very common scenario that anyone case face during development. Every developer should be familiar to have a work around to such type of common issues.


In this post, we will see how can we upload any file using ASP.NET Web Api Core 2.1 . We need to learn about CORS as we will see how we can enable CORS in order to accept cross origin resouce sharing.

Cross Origin Resource Sharing (CORS) is a W3C standard that allows a server to relax the same-origin policy. Using CORS, a server can explicitly allow some cross-origin requests while rejecting others. CORS is safer and more flexible than earlier techniques such as JSONP. This tutorial shows how to enable CORS in your Web API application.


Lets first see what do we mean by SOLID Priciples. As per the definitions given on Wikipedia:-

Single responsibility principle

a class should have only a single responsibility (i.e. changes to only one part of the software's specification should be able to affect the specification of the class).

Open/closed principle

"software entities … should be open for extension, but closed for modification."

Liskov substitution principle

"objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program."

Interface segregation principle

"many client-specific interfaces are better than one general-purpose interface."

Dependency inversion principle

one should "depend upon abstractions, [not] concretions."


Here I used code first approach of entity framework to generate the database and in that application, use jqGrid and perform the CRUD operation using jqGrid with ASP.NET MVC with async operations.

jqGrid Introduction

jqGrid is an AJAX enabled grid plugin for the java script which provides complete solutions for representing our data in the tabular format. This provides lots of features to manipulate data. Because it is a jQuery plugin it will work only on client side not on server side but for binding the data which will be on server side it can be loaded dynamically using ajax call. This is a free and open source library, which is distributed under MIT licence.

Features of jqGrid

  • Works good under IE, Chrome, Mozilla, Safari and Opera
  • CSS customizable with full Themeroller support
  • UI in 20+ languages
  • Supports Paging
  • Supports Sorting
  • Supports Insertion, Edit, Deletion, Searching, Filtering
  • Inline Editing
  • AJAX enabled
  • Accepts XML/JSON/local array data sources
  • Import and Export Data



In this post we will see how to create a proxy class of a SOAP web service using command line and wsdl.exe


We all encounter such situations where we need to update records, just like in CRUD operations. Suppose we need to create a new instance of a service. What do you think is the efficient way? Will you create a new instance of service for each update? And what if the number of users increases drastically and the performance of your application goes down? 


Any public method in a controller can be called as an action. Usually actions returns any type that derives from ActionResult. 

Similarly, ViewResult is also a action that is heavily used to return from any public method in controller as return type. View Models are classes specially created for views. They contains properties related to both domain as well as UI.

Following is the list of various Actions can be called as action.