Latest Posts

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.

 

continue...

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.

continue...

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.

continue...

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.

continue...

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."

continue...