Category: ASP.NET MVC

Web.Config Transforms

It is very common for a web applications to have different environments like follows:

  • Development
  • Staging
  • Production

There are different settings, configurations related to the application in web services (backend) or frontend which use a set of configuration defined under “Web.config”.

Web.config plays an important role in storing all the settings and configurations related to the web application. There are multiple instances where web.config defines information that controls module loading, security configuration, session state configuration and application language and compilation settings.

Connection strings are also present in web.config which vary according to the various databases used by development team.

As tracking of various settings and configuration seems (and it indeed isJ) a daunting task, it makes complete sense to have a mechanism which will provide a seamless way to pick the correct configurations according to the environments.

Enter Web.config transforms

Web.config transforms include XML markup that defines how to change web.config when it is deployed. These different changes are derived from project build configurations.

Default build configurations are Debug and Release, while custom build configurations can be created.

Build configurations

When a project is created, “Debug” and “Release” are the pre-existing build configurations.

You can create custom build configurations easily by using “Configuration Manager”.

Creating custom build configuration

In Visual Studio 2012, open a solution, and click on the drop down list for “Solution Configurations”.


Click Configuration Manager..

Configuration Manager dialog will be shown.

In the drop down list for ‘Active solution configuration’ select ‘<New…>’ and provide a name for the new configuration.

If you wish, you can use settings from other build configurations if applicable.

When done, we will need to add the config transforms related to the new configuration created.

Adding Config Transforms

Right click on web.config in the corresponding solution to see the context menu.

Select “Add Config Transforms”.

This will result in creating the transforms for the related build configuration.

For instance, I have created build configurations as – ReleaseStagingPM, ReleaseStaging, and ReleaseProduction, in addition to pre-existing Debug and Release.

The config transforms are created as below:


As shown, with respect to each build configuration, there is one web.config.

So? What it has for me?

With the use of XDT transforms, web.config transforms provide a very simple and efficient way of managing your configuration parameters.

For instance, my original web.config contains following:


<endpoint address=”http://localhost:50047/MyService1.svc&#8221; binding=”basicHttpBinding”   name=”BasicHttpBinding_IMyService1″/>

There is a web service called “MyService1.svc”. For the purpose of development and frequent debugging, I am pointing it to http(colon)//localhost(colon)50047/, which is the development environment.

Now, when I configure my respective “transformed” web.config, I use XDT transform to let web.config transforms know what pointing I am intending to change.

This is achieved by following line of code.



<endpoint address=”; binding=”basicHttpBinding” bindingConfiguration=”BasicHttpBinding_IMyService1″ name=”BasicHttpBinding_IMyService1″ xdt:Transform =”Replace” xdt:Locator =”Match(name)”/>

Now, if you observe the last two parameters, they employ XDT transform “Replace” to replace the line of code, by identifying “name”. It is highlighted in bold black font.

More syntax for XDT transform can be found at:

As a result, when I am building the web application, the “transformed” web.config will have above endpoint instead of my development environment endpoint.

In this way, an efficient use of web.config transform enables quick changes in web.config according to environments. This leads to faster deployments.

About MVC4

Hello Everyone,

I want to share some ideas about MVC4. This is useful for all kind of beginners who wanted to get started with MVC4. I learned all these things & really it’s a nice experienced for me. It is useful in future also. I just explain you following things about MVC4 in short.

  • Introduction
  • Basic Concepts
  • How MVC works?
  • Advantages
  • Features & so on…….


ASP.NET MVC 4 (Model View Controller) is open source. It helps to reduce the complexity of the web application by dividing an application into three layers, Model, View and Controller.

Steps for creating MVC4 application in visual studio 2010/1012:

  • First Select New Project from the Start page or you can use the menu and select File -> New Project.


  • You can create applications using C# or VB as the programming language. Select C# and then select ASP.NET MVC 4 Web Application.


  • Give a name to your project and then click OK.
  • Select Internet Application & Leave Razor as the default view engine & click OK.


Basic Concepts:

  • View Engines are used for designing. It is responsible for rendering the HTML from your views to the browser. The types of four view engines are as fallows:
  1. ASPX (C#)
  2. Razor (CSHTML)
  3. NHaml
  4. Spark
  • Name of different return types of controller action method are:
  1. View Result
  2. JavaScriptResult
  3. RedirectResult
  4. ContentResult
  5. JsonResult
  6. EmptyResult
  • The three segments of default route, that is present in ASP.NET MVC application are:
  1. Controller Name
  2. Action Method Name
  3. Parameter that is passed through action method
  • MVC File Structure & File Naming Standards:

It uses a standard directory structure and file naming standards. There must be 3 directories each for model, view and Controller. Expect from these 3 directories, there must have a Global.asax file in root folder, and a web.config.

  • Root
  • Controller
  • Controller CS files
  • Models
  • Model CS files
  • Views
  • View aspx/ascx files
  • Global.asax
  • Web.config


The pictorial representation of MVC framework is as follows:


An MVC application consists of Model, View and Controller.

  1. Model: It consists of the method definations, data access logic and Business Objects.
  2. View: A view is used for user interface.
  3. Controller: It call views. It consists of the main application flow logic.


The main advantages of MVC are:

  1. Enables the full control over the rendered HTML.
  2. Provides clean separation of concerns.
  3. Enables Test Driven Development.
  4. Easy integration with JavaScript frameworks.
  5. No ViewState and PostBack events

New Features in MVC4:


-It consists following features:

  • Modern HTTP programming model
  • Full support for routes
  • Model binding and validation
  • Improved testability
  • Code-based configuration
  • Create custom help and test pages
  • Link generation
  • Refreshed and modernized default project templates
  • New mobile project template
  • Many new features to support mobile apps
  • Enhanced support for asynchronous methods

If you know more about this then please share.

Thank you…..