Tuesday, April 24, 2012

WCF Contracts – an overview


As we know WCF is used to build service oriented applications. It’s been part of .net framework 3.0 and 3.5. Now we have few questions in mind like where to contact for a service, in which format I should send the message to the service, what happens if something goes wrong etc. In order to answer all these questions we have WCF defines contract to its consumers.
We can classify them into the three categories as follows
  • Service contract : Defines the operations that service exposes to its consumers
  • Data contract : Defines the structure of the data in message flow
  • Message contract : Defines the headers included in the message and how its structured
As a whole we can categorize the contracts as
  • Behavioral Contract :It defines how the service behaves, what operations it exposes, what kind of faults it issues and about the MEP (Message Exchange Pattern) to be used in interacting with the service etc
  • Structural Contracts:It simply defines the Data and Message contracts used by your WCF service. 
Well in my coming posts, we will define each of the above ones in details. Keep watching the blog posts.




Sunday, April 22, 2012

Windows Communication Foundation - Overview

Before getting into an overview of Windows Communication Foundation, it’s important to explain about SOA i.e Service Oriented Architecture. The W3C defines Service-Oriented Architecture as "A set of components which can be invoked and whose interface descriptions can be discovered and published". In simple terms SOA helps to integrate distributed applications by means of interface in terms of protocols and functionality.

With the above definition in mind, now we can move to WCF i.e. Windows Communication Foundation. It can be considered as a Microsoft’s contribution towards SOA. It is a platform, a framework if you will, for creating and distributing connected applications.

Simply we can define WCF as follows

WCF = Web Service +.Net Remoting + MSMQ + COM




Overview of ASP.NET MVC Project

Let’s now discuss about what ASP.NET MVC Framework installer does for us. We have the following changes happens with the installation

  • Registers System.Web.Mvc.dll in Global Assembly Cache (GAC) and a copy onto the \Program Files\Microsoft ASP.NET\ASP.NET MVC 1.0\Assemblies folder
  • Installs various ASP.NET MVC templates integrated with Visual Studio
  • Registers .mvc file extension with IIS

Now let’s discuss about the default MVC project structure. When we create a new ASP.NET MVC web application project, Visual studio itself provides with initial files and folder structure. It’s really important to learn about each of these items. So let’s discuss about the same as follows in brief

  • /App_Data : Stores file based database and other data files. IIS will not server its contents to public.
  • /bin : Contains all the required .net assemblies for the project.
  • /Content : Here we can place static files like .css which can be served to public
  • /Controllers : Project specific controller classes (derived from Controller or implements IController)
  • /Models : We place all domain model classes
  • /Scripts : We can store all static script files inside this folder
  • /Views : Holds .aspx or .ascx files
  • /Views/Shared : View templates which are not associated with any controllers
  • /Views/Web.config : This is not application’s main config file, instead it directs not to serve any .aspx files directly.
  • /Default.aspx : This is not relevant for ASP.NET MVC application but it is required for IIS6 compatibility.
  • /Global.asax : Defines global ASP.NET application object, registers your routing configuration etc. It serves the same purpose as ASP.NET Web forms.
  • /Web.config : Defines application configuration

Apart from the above common files and folders, we have certain optional files and folders as follows which serves different purposes

  • /App_GlobalResources/App_LocalResources : Stores resource files required for localization
  • /App_Browsers : Contains . browser xml file
  • /App_Themes : Contains themes and skin file
Apart from this we need to consider the naming conventions in ASP.NET MVC since it relies on convention over configuration. So the following points are really important

  • Controller classes name should end with “Controller”
  • View templates should go into /Views folder only
  • The default view for an action method should be named after the action method.
  • /Views/Shared can be used to share views across multiple controllers

So here we conclude this post just briefing about the initial files and folder structure of ASP.NET MVC project. Please note that this is not a mandatory structure for any real project scenario.

Wednesday, April 11, 2012

ASP.NET MVC Framework

Everyone is familiar with MVC i.e. at least we have been hearing this term for long in software engineering. I never been to MVC but now decided to learn basics of MVC. So what exactly is MVC is all about?

Simply by expansion it is Model View Controller. It is an architectural pattern which describes the interaction between users and application in three different roles Model (business logic), View (User interface), Controller (User input). Let’s now discuss how the interactions occur in MVC as follows

  • User interacts with the user interface with some input action (like button click)
  • Controller handles the input event and converts into an action that model knows
  • Model’s state is changed with the controller’s notification
  • View queries model to generate the Model to generate the user interface

MVC facilitates a separation of concerns, maintainability and testability of the application development.

Now ASP.NET MVC Framework is a web application framework which implements MVC pattern. So let’s see the few facts about ASP.NET MVC framework as follows

  • It supports separation of application tasks, testability and test driven development. All contracts are interface based and easy to mock and unit test.
  • Easy to extend, customize and plug our own components.
  • It has a powerful URL mapping component which helps to provide a SEO friendly URLs
  • Still we have the advantage of using existing ASP.NET page, user controls and master pages as well.
  • Supports all the existing features like windows and forms authentication, membership and roles concept etc.
  • It does not use view state or server based controls and hence provide complete flexibility for developers
  • It relies n Front controller pattern and hence processes all requests through single controller
  • Better support for test driven development.

It’s all depends on our decision whether to go for MVC based Web application or Web forms based Web application. Keep watching this blog for more posts in MVC on a daily basis J

Installing ASP.NET MVC

Installing ASP.NET MVC Before we dive deep into the ASP.NET MVC, let’s install it our development machine. This is very straight forwa...