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

Thursday, June 23, 2011

Plan for User Accounts – complete SharePoint installation

We have two different approaches towards SharePoint installation such as Standalone installation and Complete installation. Standalone installation is meant for a single server installation scenario where we install everything on a single machine. While Complete installation here refers to farm level installation of SharePoint by separating out the concerns and accessed remotely in the same network infrastructure.

For a complete installation we should draw clear plan around the approach, here the plan for User accounts stands as a critical one among the various requirements. As we know it is desired to have different user accounts for accessing different resources in a network in an efficient manner. So I thought this is the right time to jot down an introduction to various User accounts as follows

SETUP ACCOUNT:

Setup account is the one which is used to run the SharePoint preparation tool, installation and configuration wizards, to create root file structure, assign rights to different accounts etc. It is preferred to be a Domain Admin or member of the Administrator group with SQL Login, security admin and dbcreator roles.

SERVICE ACCOUNTS:

For a single server environment, the network service/local service accounts will work fine for all SharePoint’s services. But when it comes to Farm level installation, it is preferred to have different accounts for various services. So here we have the following Service accounts to be considered as follows

Farm Account: It is the account used by all SharePoint servers in the farm to access the farm’s configuration database and run SharePoint specific services. This is created during the installation of SharePoint. Also it is the SharePoint Timer Service account and application pool identity for Central Administration.

Search Account: This account act as the owner of the Search database and responsible for managing the SharePoint Search.

Index Account: This is known as another owner of the Search database, content access account, crawler, gatherer, and indexer.

Content Database Account: This account act as the owner of the Content database of a web application.

BDC Account: This is used by SharePoint to pass data back and forth between a user, SharePoint and an external data sources using Business Data Connectivity Service. It supports Claims-based authentication.

Sandboxed Code Service Account: It is used by SharePoint to manage solutions that are deployed in a “sandboxed” fashion, not to whole farm but to a single site collection.

So we summarized about the various User accounts to be considered while doing a Complete Farm level installation of SharePoint.

Wednesday, June 22, 2011

Working with Macro Parameters – Razor approach

As we know we can supply values for parameters on Macros. When we insert a macro onto a template, we are prompted to supply the values for the parameters. Here I would like to show you that we can also do this in a Razor script as well.

Let’s say we have a Razor script file called “WelcomeMessage.cshtml” created under the Scripting files and we have a corresponding macro called “Welcome Message Macro”. The duty of our Razor script here is to display a Welcome message. Well, we have set a macro parameter called “AttendeeName” which accepts a name when inserted on a template. Now we need to modify our welcome message to display as “Welcome [AttendeeName], have a nice time here!!!”. Here in the given message [AttendeeName] should be replaced by the value assigned as a macro parameter.

This can be easily implemented in Razor script. In order to implement this, we need to make use of the following syntax in Razor scripts as follows

@Parameter.AliasName (please note this is not case sensitive)

So in our scenario, the whole Razor script would be as given below

Welcome @Parameter.AttendeeName, have a nice time here !!!

So guys have fun with Razor :-)

Access Property Data in Umbraco – Razor approach

In my last post I had discussed about Razor in Umbraco. Now let me share more about the implementation part of Razor in Umbraco. As we know Razor can be used in scenarios where we had used XSLT.

Here I would like to use Razor syntax to access document property data in Umbraco. We have a variable called @Model in Razor which is equivalent to the $currentPage in XSLT. Similarly we can use Razor to access all the properties like .Name , .Url ,.Level , .Id etc using @Model. Also we have option to access the custom property associated with a document type.

We can write Razor syntax in two modes i.e. Inline Razor approach or dedicated approach. Inline Razor approach is the style of writing the Razor syntax in line with the HTML snippets inside a template. While dedicated Razor approach refers to the style of writing Razor snippets separately under the scripting files. Then we associate this to a Macro and insert it onto the template.

Let me write a Razor snippet to access the property data in Umbraco, it will display the Name and Url of the page.




Now similarly we can access the Custom properties as well. Let’s have the following code snippet which access a Custom property called “myProperty



So we have learned a bit on how to access property data using Razor syntax. I believe all C# folks would like this approach as they can do the similar things as fast as it is done in XSLT approach.

Saturday, March 19, 2011

Razor in Umbraco

As you know Razor is the ASP.NET view engine. I have already posted an introduction to Razor in my blog. Now let’s talk about the concept of Razor in Umbraco. Umbraco team has considered Razor in their version 4.6 onwards and it’s robust in version 4.7 of Umbraco.

We already knew the importance of XSLT in Umbraco as we use it for creating the lists, navigations, breadcrumbs and iterating through the Umbraco nodes etc. Razor is optimized around HTML generation in a code focused approach. Razor can be used in scenarios where we can use XSLTs. We can exploit the skills of .NET developers with Razor as it works well with C# or VB knowledge. The Razor source code has extension either .cshtml/.vbhtml. We can use Razor scripting either in template via Macro or directly inside the HTML templates inside Umbraco.

Lets brief the advantages of using Razor scripting is as follows

  • Compact, Expressive and Fluid
  • Easy to learn
  • Not a new language
  • Works with any text editor
  • Great intellisense in Visual Studio.

We can use Razor scripting in Umbraco either as inline scripts, we can access Umbraco property data, work with macro parameters, list sub pages from current page, list subpages by level etc. You can watch for more posts in Razor with Umbraco in coming days.

For further information please visit the http://umbraco.com/help-and-support/video-tutorials/umbraco-fundamentals/razor/introduction-to-razor-in-umbraco

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