Skip to main content

What are the Differences between the Debug class and Trace class?

Debug and Trace both classes are included in Systems.Diagnostics namespace and have very similar methods. The main difference is that call to Debug class is included in Debug mode only while call to Trace class will be included in Debug as well as Release mode also.

So in short we can say it is advisable to use Debug at the time of application development, while Trace option is used at the time of application deployment, like we can trace any error and write it into log files etc.

What is the differences between a Debug and Release build?

When we are building any .Net project there are two configuration we can select 1 is Debug and another is for Release, While we are developing an application default mode is Debug and programmers keeps is Debug mode for debugging code step by step or line by line. Once project is completed we need to change it to Release mode before generating final build like DLL, EXE or published code.

The Debug mode does not optimize the binary it produces because the relationship between source code and generated instructions is more complex. This allows breakpoints to be set accurately and allows a programmer to step through the code one line at a time. The Debug configuration of your program is compiled with full symbolic debug information which help the debugger figure out where it is in the source code.

Normally Debug builds are not optimized and it has debugging symbols, while the code build in the Release mode is more optimized, It is very less in size and more faster then Debug mode.

What is the role of .pdb files ?
PDB is stands for Program Database File, it contains the debug information about the application depending on the compiler option that we have used. It holds application state information and debugging information that allows incremental linking of a Debug configuration of out application. PDB file is created when we are running a C# application in Debug mode.

We can set the debug mode in web.config file as shown below

// For Debug mode

<compilation debug="true">


// For Release mode

<compilation debug="false">

Happy Debugging


Asp.Net Web API is a framework for building HTTP services that can be consumed by a broad range of clients including web browsers, mobile phones and tablets. Actually Web API is not a part of MVC Framework, however it is very similar to Asp.Net MVC Framework, It provides similar feature like controller, action results, routing, model binders, filters, dependency injection or Inversion of Control container. It is a part of standard Asp.Net Framework so it can be used with Asp.Net Web Forms as well as Asp.Net MVC. It can be used as a stand alone application like web services. Asp.Net Web API is a very good platform to build a RESTful application.

Nova days web application is not capable to reach more customers, as people using smart phones and tablets in their daily routine life for making their life easy. In short we can say people are moving from web to mobile devices.

So if you want to delivered data fast and in a simple manner for web browsers and smart devices then Web API is a good choice for that because it is compatible for those devices and browsers.

See the below image for the reference

Cool features of Web API

  1. ASP.NET Web API is Very good platform for building RESTful services.
  2. ASP.NET Web API maps HTTP verbs to method names.
  3. Responses have an Accept header and HTTP status code.
  4. ASP.NET Web API is built on top of ASP.NET.
  5. Asp.Net Web API supports ASP.NET request/response pipeline
  6. Asp.Net Web API supports convention-based CRUD Actions since it works with HTTP verbs GET, POST, PUT and DELETE.
  7. Responses are formatted by Web API’s MediaTypeFormatter into JSON, XML or whatever format you want to add as a MediaTypeFormatter.
  8. ASP.NET Web API supports different formats of response data. Built-in support for JSON, XML format.
  9. ASP.NET Web API can be hosted in IIS, Self-hosted or other web server that supports .NET 4.0+.
  10. It may accepts and generates the content which may not be object oriented like images, PDF files etc.
  11. ASP.NET Web API also supports for Odata. So if we add a new [Queryable] attribute on a controller action method which returns Iqueryable, clients can use the method for Odata query composition.
  12. Asp.Net also supports the MVC feature such as controller, routing, filters, action results, model binder, IOC container/dependency injection that makes it more simple and robust.

Why we choose Web API?

  1. First of all it is an open source.
  2. It only based on HTTP and easy to define, easy to expose and easy to consume in a RESTful way.
  3. It is very good for those devices which has very limited bandwidth like smart phone, tablets etc, Because it is very light weight architecture.
  4. It does not have any complex and extensive configuration like WCF services.
  5. Asp.Net Web API is the best choice when we don’t need SOAP and only need a web services.
  6. Asp.Net Web API is used to build simple non-SOAP base HTTP services on top of the already build WCF message pipeline.

When to choose Asp.Net Web API or Web API?

  1. If you are using .Net framework greater then or 4.0
  2. If we want to develop services which supports only HTTP protocol.
  3. If you are familiar with Asp.Net MVC then go for Web API.
  4. If you want to build RESTful HTTP based services then go for Web API

When to choose WCF services

  1. If you want to use Request-Reply, duplex message exchange patterns or one way then choose WCF services.
  2. If you want to use .Net framework below 4.0
  3. If you want to build a services with WS-* standards like Reliable messaging, Message Security or Transaction then go for WCF services.
  4. If you want to develop a services which not supports only HTTP and supports TCP and Named pipe then go for WCF services.

Difference between WCF and Web API

For the WCF and Web API Difference please refer my previous article.

Web API Version

API Version Supported Framework As.Net MVC Version Visual Studio Version
Web API 1.0 .Net Framework 4 Asp.Net MVC 4 Visual Studio 2010
Web API 2 .Net Framework 4.5 Asp.Net MVC 5 Visual Studio 2012Visual Studio 2013

I think you have now clear picture about Web API. Please share your valuable feedback here  in comments.

In our next article we will see the Web API in real action with small example with Visual Studio.