Skip to main content

Posts

What is Web API and why should we use it ?

Asp.Net Web API is a framework for building HTTP services that can be consumed by a broad range of clients including browsers, mobiles, iphone and tablets. It is very similar to ASP.NET MVC since it contains the MVC features such as routing, controllers, action results, filter, model binders, IOC container or dependency injection. But it is not a part of the MVC Framework. It is a part of the core ASP.NET platform and can be used with MVC and other types of Web applications like Asp.Net WebForms. It can also be used as an stand-alone Web services application. Why Asp.Net Web API (Web API) ? Today, a web-based application is not enough to reach it's customers. People are very smart, they are using iphone, mobile, tablets etc. devices in its daily life. These devices also have a lot of apps for making the life easy. Actually, we are moving from the web towards apps world. So, if you like to expose your service data to the browsers and as well as all these modern devices apps ...

ASP.NET Web API and ELMAH Integration

As you all probably heard,  ASP.NET MVC 4  Beta is now available and has new features in it. One of them is that ASP.NET MVC has shipped with  ASP.NET Web API  (which was previously know as  WCF Web API ). Here is the quote from ASP.NET web site which explains what Web API Framework is all about shortly: ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework. I am not going to give an into on ASP.NET Web API. There are great into tutorials and videos on ASP.NET web site for ASP.NET Web API. Instead, I will give you an example of a custom filter implementation. A couple of months ago, I wrote a blog post about  WCF Web API HttpErrorHandlers :  WCF Web API Plays Nice With ELMAH - A Quick Introduction to WCF Web API HttpErrorHandler . It works nicely on WCF Web AP...

SVN Dos and Dont’s

The Dos and Dont’s Dos Don’ts Check out the latest revision  before start working, and check your changes back in as soon as possible. Don’t use  svn locks . Commits in subversion are transactional and locks are almost always unnecessary. Commit often , one change at a time. Easier to read and debug. Don’t include multiple changes in a single large commit. Look at the diff before committing , make sure you can answer the question: what are you changing? You’ll need the answer for the next point. Don’t tidy up the code while making changes. If tidying up is necessary, do it in a separate commit (see Bruno’s  comment ). Document changes  in the commit message, use the -m switch in the command line or the entry field provided by TortoiseSVN or other SVN-GUIs. Don’t leave the message field empty. If the change requires more than a few lines of explanations, consider breaking it down into multiple commits. Reference  tracker ...

What is n-Tier Architecture?

This is a very important topic to consider when developing an application. Many elements need to be considered when deciding on the architecture of the application, such as performance, scalability and future development issues. When you are deciding on which architecture to use, first decide on which of the three aforementioned elements you think is most valuable -- as some choices you make will impact on others. For example, some choices that boost performance will impact on the scalability or future development of your design, etc. Here we will talk generally about what n-Tier architecture is, and then we will have a look at different n-Tier architectures you can use to develop  ASP.NET applications and issues that arise relating to performance, scalability and future development issues for each one. Firstly, what is n-Tier architecture? N-Tier architecture refers to the architecture of an application that has at least 3 "logical" layers -- or parts -- that are separat...

POCO Classes in Entity FrameWork

A Plain Old CLR Objects (POCO) is a class, which doesn't depend on any framework-specific base class. It is like any other normal .NET class. Due to this, they are called Plain Old CLR Objects. These POCO entities (also known as persistence-ignorant objects) support most of the same LINQ queries as Entity Object derived entities. These classes (POCO classes) implements only the domain business logic of the Application. Some developers use Data Transfer Objects (DTOs) with the classes to pass the data between the layers because POCOs are also used to pass the data between the layers, but they become heavy. Hence they use DTOs, which are also theclasses. The main difference between DTO and POCO is that DTOs do not contain any methods. They only contain public members. Thus, sending the data, using a DTO is easy because they are lightweight objects.   The code given below defines a POCO class. If you want to create POCO classes instead of the entity classes or a defa...

PLinq

Introduction Most .NET developers today are familiar with  LINQ , the technology that brought functional programming ideas into the object-oriented environment.  Parallel LINQ , or ‘ PLINQ ’, takes  LINQ  to the next level by adding intuitive parallel capabilities onto an already powerful framework. PLINQ  is a query execution engine that accepts any LINQ-to-Objects or LINQ-to-XML query and automatically utilizes multiple processors or cores for execution when they are available. The change in programming model is tiny, meaning you don’t need to be a concurrency guru to use it. Using  PLINQ  is almost exactly like using LINQ-to-Objects and LINQ-to-XML. You can use any of the operators available through C# 3.0 syntax or the  System.Linq.Enumerable  class, including  OrderBy, Join, Select, Where , and so on. LINQ-to-SQL  and  LINQ-to-Entities  queries will still be executed by the respective databases and query pro...

How to Count the Lines of Code (LOC) in your application using Visual Studio

There is a tool called Code Metrics in Visual Studio 2013 and 2015 that among other things, counts the lines of code in a project. Using Code Metrics is very simple. In Solution Explorer, select the project that you want to know the LOC for, right-click and select "Calculate Code Metrics". One of the nice things about the Code Metrics window is that it shows you the lines of code per project, namespace, class or method.