Tuesday, March 27, 2012

AppFabric Installation Guide

Download AppFabric from the following link based on caching deployment machine. 

Installation Steps:

Accept the licence agreement and click “Next>”.

Click “Next>”.

Select all options and click “Next>”.

Click “Next>”.

Click “Install”.

Click “Finish”. Then AppFabric Configuration Wizard will be available to configure cluster.

Click “Next>”.

Click “Next>”.

Check “Select Caching Service Configuration” and select “XML” in Caching Service Configuration provider”.
Give the valid shared folder name in “File Share” path.
Select the required Cluster Size from the dropdown(Small, Medium and Large).

Click “Next>”.

Select “Yes”.

Click “Finish”.

Run Caching Administration Windows PowerShell.
And Start the Cache cluster using the command “Start-CacheCluster”.

Saturday, September 24, 2011


  • Routing is used by the ASP.NET MVC framework to route incoming requests to controller actions. 
  • Routing uses a route table to handle incoming requests. This route table is created when your web application first starts. The route table is setup in the Global.asax file. 
  • When an ASP.NET application first starts, the Application_Start() method is called. This method calls the RegisterRoutes() method and the RegisterRoutes() method creates the default route table. 
  • The default route table consists of one route. This default route breaks all incoming requests into three segments (a URL segment is anything between forward slashes). 
  • The first segment is mapped to a controller name, the second segment is mapped to an action name, and the final segment is mapped to a parameter passed to the action named Id.
    1)    Url: http://localhost /User/UserDetails/3
Controller = User, Action = UserDetails, Id = 3   

    2)    Url: http://localhost /User
Controller = User, Action = Index, Id = “”

The Default route defined in the Global.asax file includes default values for all three parameters. The default Controller is Home, the default Action is Index, and the default Id is an empty string. 

    3)    Url: http://localhost /
Controller = Home, Action = Index, Id = “”

More Examples
Controller Class
Action Method
Parameter Passed
Id = 1
Id = 1

Tuesday, December 21, 2010


Views - Introduction

  • The View is responsible for providing the user interface (UI) to the user.
  • Views should not contain application and business logic.
  • View Engine is used to generate views. The default view engine is WebFormViewEngine.
  • Views in ASP.NET MVC derive from a common base class, System.Web.Mvc.ViewPage, which itself derives from System.Web.UI.Page. Strongly typed Views derive from the generic ViewPage<T>.
  • View is able to take advantage of Master Pages, one of the benefits of building on Views on top of the existing ASP.NET Page infrastructure.
  • ASP.NET MVC provides a library of helper methods used to output properly encoded HTML, which provides a lot of help in creating Views.
  • A view renders the appropriate UI by using the data that is passed to it from the controller. This data is passed to a view from a controller action method by using the View method.

View Structure

  • When we create a new ASP.NET MVC application, the project contains “Views” directory structured in a very specific way. See the following figure

  • The Views directory contains a folder per Controller, with the same name as the Controller, sans the “Controller” suffix. Within each Controller folder, there’s a View file for each action method, named the same as the action method.
  • The action method can return a ViewResult via the View method like,

public ActionResult Index()
ViewData["Message"] = "Welcome to Balamurugan Nattarasan Blog!";
                   return View();

  • If the View name is not specified in the ViewResult then the View name same as the action name in the /Views/ControllerName directory.
  • In the above example, the View would be /Views/Home/Index.aspx.
  • The View method calls the view engine, which uses the data in the list to render to the view and to display it in the browser.
  • The View can be overridden. You want the Index action render a different then you could pass different View name like,

public ActionResult Index()
ViewData["Message"] = "Welcome to Balamurugan Nattarasan Blog!";
                   return View("TestMethod");

  • You want to specify the View in a completely different directory structure, then you can use tilde (~) symbol to provide the full path to the View like,

public ActionResult Index()
ViewData["Message"] = "Welcome to Balamurugan Nattarasan Blog!";
                   return View("~/Test/TestMethod1.aspx");

  • When using the tilde syntax, you must supply the file extension of the View because this bypasses the View engine’s internal lookup mechanism for finding Views.

View Pages
·         A view page is an instance of the ViewPage class. It inherits from the Page class and implements the IViewDataContainer interface.
·         The ViewPage class defines a ViewData property that returns a ViewDataDictionary object. This property contains the data that the view should display.
·         The MVC framework uses URL routing to determine which controller action to invoke, and the controller action then decides which views to render.

Master-Page Views
·         ASP.NET page views (.aspx files) can use master pages to define a consistent layout and structure. In a typical site, the master page is bound to a content page in the @ Page directive of the content page.
·         You can also use dynamic master pages (that is, you can assign a master page at run time) when you call the View method of the Controller class.

Partial Views
·         A partial view enables you to define a view that will be rendered inside a parent view. Partial views are implemented as ASP.NET user controls (.ascx).
·         When a partial view is instantiated, it gets its own copy of the ViewDataDictionary object that is available to the parent view. The partial view therefore has access to the data of the parent view.
·         However, if the partial view updates the data, those updates affect only the partial view's ViewData object. The parent view's data is not changed.

Shared Views
·         The ASP.NET MVC framework always attempts to retrieve a view from the Shared folder when the view can’t be retrieved from the Views subfolder that corresponds to the controller’s name. This means that you can create default views for action methods that are shared across multiple controllers.
·         For example HomeController exposes an action named Index(). When the Index() action is invoked, the ASP.NET MVC framework first attempts to retrieve the Index view from the following path:
·         If the Index.aspx view is not present in the Home folder, the ASP.NET MVC framework next attempts to retrieve the view from the Shared folder:
·         If the Index.aspx view can’t be retrieved from either location, then the error message will be displayed.