QuestPond: Interview Questions and Answers on learning ASP.NET MVC (Model View Controller)

What is Bundling and Minification in ASP.NET MVC?


In normal scenario let say for an instance,

  •  User makes a request to index action in customer controller.
  • Action method will return a view result.
  • Now the view contains reference to 3 js files and 3 css files.
  • When browser receives the view in response, it comes to know about these references so it will make 6 more requests to server asking for the referenced files.

It will affect the overall response time of the view. To get one complete view browser makes 7 requests (one for view, 3 for js and 3 for css). Now imagine the situation when we have more number of css and js files. 🙂 🙂

Bundling is the solution for the same.
It let us combine multiple files into one file at runtime. Using this concept we can create bundles of js and css files. Fewer files mean fewer response times and it means quick response time.


Normally how we write or JavaScript and css. We follow following rules normally while writing css or js.

  • We use proper indentation
  • We properly add spaces
  • We use enter properly
  • We use meaning full names for defining variables
  • Write comments wherever we write complex logic

What next? 😦 It will affect the size of the file. File size will be increased and thus increased download time.

Solution is Minification. Minification is a technology which will reduces the size of the file at runtime by removing unnecessary whitespaces, comments and shortening variable names.

How to perform bundling and Minification?

Step 1: Add reference of System.Web.Optimization to your project

Step 2: In global.asax create the bundles as follows

BundleTable.Bundles.Add(new ScriptBundle("~/bundles/jquery").
("~/Scripts/jquery-2.1.1.js", "~/Scripts/jquery.validate.js", 

Step 3: Enable optimization in global.asaxasfollws

BundleTable.EnableOptimizations = true;

Step 4: In the view include bundle as follows







For technical trainings on various topics like WCF, MVC, Business Intelligence, Design Patterns, WPF, TFS and Basic fundamentals feel free to contact or visit

For more stuff like this, click here. Subscribe to article updates or follow at twitter @SukeshMarla

See following video on implementing ASP.NET (Model View Controller) MVC Web API: –


If you want to learn more about bundling and Minification then go through following video from our


About c# and .NET Interview questions

This blog is for developers who want to crack .NET and C# interviews. It has all tips and tricks needed to crack .NET interviews , C# interview , SQL Server interview , Java interview , WCF Interview , Silverlight interview , WPF interview , LINQ interview , Entity framework Interview. Do not forget to watch our Learn step by step video series. Learn MVC in 16 hours:- Learn AngularJS Step by Step:- Learn Design Pattern in 8 hours:- Learn C# and .NET in 60 days:- Learn MSBI in 32 hours:- Learn SharePoint Step by Step in 8 hours:-
This entry was posted in Uncategorized and tagged , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s