Wednesday, 24 July 2019

Interview question one line on Angular

Sl No Questions Keyword Answer Example
1 What does "npm install -g" mean? To install npm package global level
2 What is Angular CLI It is command line interface which helps to get basic setup of angular project  npm install -g  @angular/cli
ng new project-name
cd project-name
ng serve
3 How to create app using Angular CLI? ng new project-name
cd project-name
code . (to open project in Visual studio code editor)
ng serve
4 Differentiate between ng serve and ng builld? ng serve - Is use to run application in In-memory (inside RAM) taking whole application compling hosted in http://localhost:4200/
ng build - To
5 What do folder "src", "dist" and "e2e" contain? Src - (source folder) All source code
dist - (distribution folder) All build js will be saved after running ng build command
e2e - (end to end testing folder) For testing purpose
6 what is importance of angular.json file in Angular cli? Workspace is a directory which is generated via Angular CLI 
7 What are components and modules in Angular Components - Class file which will interact with UI i.e., html files
Modules - Which is used to group components, directives, pipes and services 
8 What is use of TemplateURL  which connects components and html page
9 Explain modules Which is used to group components, directives, pipes and services   @NgModule({
   declarations: [
      AppComponent
   ],
   imports: [
      BrowserModule
   ],
   providers: [],
   bootstrap: [AppComponent]
})
10 What is use of Bootstrap in Modules Out of many components, Bootstrap helps for starting the execution
11 Which file defines the start module of angular project Main.ts files
PlatformBrowserDynamic method from @angular/PlatformBrowserDynamic  library
platformBrowserDynamic().bootstrapModule(MainModule)
12 What is Import in module To import angular library to NgModule
import statement on top is used by typescript

import { FormsModule } from '@angular/forms';
For import statement
import { FormsModule } from '@angular/forms';

Import in @NgModule
imports: [
   BrowserModule,
   FormsModule
]
13 What is Provider in module Will include in services created
14 What will happen if polyfills are not used make our Angular application compatible for different browsers.

Angular code in ES6(New Features: Overview and Comparison) and is not compatible with IE or firefox and needs some environment setups before being able to be viewed or used in these browsers.
Polyfills.ts was provided by angular to help you do away with need to specifically setup everything.
15 What is need of Webpack Webpack is a module bundler, but you can also use it running tasks as well
16 How to use *ngFor Loop directive NgFor is a directive that iterates over collection of data
17 Explain ^ and ~ for version resolution ^  Latest minor version
~  Latest revision version
6.1.0
6 is major version
1 is for minor version
0 is for revision version
18 Can we have Angular UI without a component No
19 What is routing Collection Routing collection is nothing but where we specify URL and component which is loaded
20 Explaing the importance of [routerLink] in href element To naviage between routes <a [router-link]="['home']">Home</a>
21 What is importance of router-outlet element in routing router-outlet is directive which tell router to render the content in view <router-outlet></router-outlet>
22 Explain importance of loadChildren To achieve lazy loading routing
23 How is URL structured for loadChildren ../Customer/CustomerApp.CustomerModule#CustomerModule
Customer - folder or path
CustomerApp.CustomerModule - Filename or path
#CustomerModule - After # Class to be loaded
24 Explain importance for forRoot and forChild forRoot - For eager loading
forChild - For lazy loading
25 What the importance of Dirty Flag, pristine, touched, untouched, valid, invalid Dirty flag - indicates user has changed values
Pristine - opposite of dirty flag
Touched - indicates field is touched by user
Untouched - Opposite of touched
Valid - Checks whether all validation have passed
Invalid - opposite of valid
26 When do we need to provide standalone option Control which is inside FormGroup without validation is to be provide standalone option [ngModelOptions] = "{ standalone : true }"
27 What is benefit of DI dependency injection is a technique whereby one object  supplies the dependencies to another object
28 What are two kinds of DI Centralized DI
Conditional DI
29 Explain importance of injector Injector is used to achieve conditional based DI. 
30 Define reusable user controls Reusable code snipnet of UI which we can plug into any HTML
31 Explain inputs, output and event emittes  @Input is a decorator to mark an input property and @Output is a decorator to mark an output property.
EventEmitter is really an Angular abstraction, and should be used pretty much only for emitting custom Events in components
32 which of the below naming convention is good for a custom user control
myTextBox
my-texbox
my-textbox - because it should not get confict with html tag which might release in future
33 Which notatin will you use when data flows from user control to main UI
[]
()
[]
34 How to use HTTP component To call to server via restful servcie
35 Why DTO is a better way of transferring data To avoid circular dependency error
36 In new project should we use HTTP or HTTP client HTTP client
HTTP is deprecated from Angular 7
37 What is importance of DI in using HTTP component As we want to migrate from Angular 6 to 7. We don’t need to change too much of code
38 What are interceptors in httpclient To set security key in http header call
39 how to create fake server json-server
40 explain the importance of integrated terminal in VS code? We can create more terminals
like for run fake server via json-server which use port 3000
and other we can use for ng serve to run angular application port 4200
npm install -g json-server
json-server --watch db.json

Sunday, 12 February 2017

Interview question one line on AngularJS

Sl No Questions Keyword Answer Example
1 What is AngularJS ? Angular is a declarative JavaScript framework to simply JavaScript code
2 Explain Directives in Angular? Directives are attributes decorated on the HTML elements. All directives start with the word “ng” ngBind,
ngModel
ngClass
ngApp
ngInit
ngRepeat
3 Explain ng-app It is the most important directive for an Angular Application, which is used to indicate starting of an Angular Application to AngularJS
4 Explain ng-init ng-init directive is used to initialize an AngularJS Application data variable's inline statement <body ng-app="myApp" ng-init="pi=3.14">
The value of pi is {{pi}}
</body>
5 Explain ng-model ng-model directive is used to define the model/variables value to be used in AngularJS Application’s HTML controls like <input type=’text’/>
It also provides two-way binding behavior with the model value
6 Explain ng-bind ng-model directive is used to define the model/variables value to be used in AngularJS Application’s HTML controls like <input type=’text’/>
It also provides one-way binding behavior with the model value
7 Explain ng-repeat ng-repeat directive is used to repeat HTML statements
8 What are controllers and need of ng-controller and ng-model in Angular? “Controllers” are simple javascript function which provides data and logic to HTML UI function Customer($scope)
{
        $scope.CustomerName = "Shiv";
        $scope.CustomerCode = "1001";
        $scope.Add = function () {
        }
        $scope.Update = function () {
        }
}

<div ng-controller="Customer">
<input type=text id="CustomerName"  ng-model="CustomerName"/><br />
<input type=text id="CustomerCode"  ng-model="CustomerCode"/>
</div>
9 What are expressions in Angular? code which resolves to value or to display the variable {{1+1}}
10 How can we initialize Angular application data? We can use “ng-init” directive to achieve the same <body ng-app="myApp" ng-init="pi=3.14">
The value of pi is {{pi}}
</body>
11 Explain $scope in Angular? “$scope” is an object instance of a controller
and it is an angular service for Angular scope management
12 What is “$rootScope” and how is it related with “$scope”? “$rootScope” is a parent object of all “$scope” angular objects created in a web page.
13 Explain the concept of digest cycle, watchers and dirty checking? Digest cycle: - It is a simple loop which updates the model and view.
Watchers :- They are listeners which are attached to expression and angular directives and fire when the model data changes.
Dirty check :- This is a extra digest loop which runs to check any cascading left over updates due to the first digest cycle.
14 What can be the performance implications of watchers and digest cycle ? As per AngularJS team having more than 2000 watchers on Angular screen is a bad practice.
15 How can we measure no: of watchers & time spent on digest cycle? Batrang tool from Google extension
16 How can we decrease digest cycle time ? Remove unnecessary watchers.
Use one time Angular binding. Especially if you see ng-repeat loop apply one time binding.
17 Can we force the digest cycle to run manually? $scope.apply()
18 Do I need jquery for Angular? No
19 How is the data binding in Angular ? Two way binding
20 Explain compile and link phase? Angular parser works in 3 steps:-
Step 1:- HTML browser parses the HTML and creates a DOM (Document Object Model).
Step 2:- Angular framework runs over this DOM looks at the Angular directives and manipulates the DOM accordingly.
Step 3:- This manipulated is then rendered as HTML in the browser
21 How do we make HTTP get and post calls in Angular? “$http” service API needs atleast three things:-

First what is the kind of call “POST” or “GET”.
Second the resource URL on which the action should happen.
Third we need to define the “success” function which will be executed once we get the response from the server.
function CustomerController($scope,$http)
{
 $scope.Add = function()
 {
            $http({
                 method: "GET",
                url: "http://localhost:8438/SomeMethod"
           }).success(function (data, status, headers, config)
  {
                   // Here goes code after success
  }
 }
}
22 How do we pass data using HTTP POST in Angular ? You need to pass data using the “data” keyword in the “$http” service API function Var myData = {};
myData.CustomerName = “Test”;
$http({ method: "POST",
 data: myData,
 url: "http://www.xyz.com"})
 .success(function (data, status, headers, config)
 {
   // Here goes code after success
 })
23 What is dependency injection and how does it work in Angular? Dependency injection is a process where we inject the dependent objects rather than consumer creating the objects function CustomerController($scope,$http)
{
// your consumer would be using the scope and http objects
}
24 How does DI benefit in Angular? There are two benefits of DI
1) Decoupling
2) Testing
25 What are services in Angular? Service helps to implement dependency injection.
26 Are Service object instances global or local? Global
27 What is a Factory in Angular? the purpose of Factory is also same as Service however in this case we create a new object and add functions as properties of this object and at the end we return this object var app = angular.module("myApp", []); // creating a APP
app.controller("CustomerController", CustomerController); // Register the VM
app.factory("Customerfactory", CreateCustomer);
28 What is the difference between Factory and Service? AngularJS Service: is used for sharing utility functions with the service reference in the controller. Service is singleton in nature so for once service only one instance is created in the browser and the same reference is used throughout the page

AngularJS Factory: the purpose of Factory is also same as Service however in this case we create a new object and add functions as properties of this object and at the end we return this object
29 How are validations implemented in Angular? !frm1.CustomerName.$valid
30 How to check error validation for a specific field? !frm1.CustomerName.$valid
31 What does SPA (Single page application) mean? SPA is a concept where rather loading pages from the server by doing post backs we create a single shell page or master page and load the webpages inside that master page
32 How can we implement SPA with Angular? Angular-route.js or Angular-ui-route.js
33 How to implement routing in Angular? Step 1: - End user clicks on a hyperlink or button and generates action.
Step 2: - This action is routed to the route provider.
Step 3: - Router provider scans the URL and loads the view in the place holder defined by “ng-view” attribute.
Step 1: - Add the “Angular-route.js” file to your view.
<script src="~/Scripts/angular-route.js"></script>
Step 2: - Inject “ngroute” functionality while creating Angular app object.
var app = angular.module("myApp", ['ngRoute']);
Step 3: - Configure the route provider.
app.config(['$routeProvider',
            function ($routeProvider) {
                $routeProvider.
                        when('/Home', {
                            templateUrl: 'Yoursite/Home',
                            controller: 'HomeController'
                        }).
                        otherwise({
                            redirectTo: '/'
                        });
            }]);
Step 4: - Define hyperlinks.
<div>
<a href="#/Home">Home</a><br />
<a href="#/Search"> Search </a><br />
</div>
Step 5: - Define sections where to load the view.
<div ng-view>

</div>
34 How to implement SPA using angular-UI route? myApp.config(function ($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('Home', {
            url: '/HomePage',
            templateUrl: 'Home.htm'
        })
        .state('About', {
url: '/About',
            templateUrl: 'About.htm'
        })};

<a ui-sref="About" href="#About">Home</a>
<a href="#Home">About</a>
<ui-view></ui-view>
35 Can we load HTML content rather than a full page ? using “template” property myApp.config(function ($stateProvider, $urlRouterProvider) {
    $stateProvider
          .state('About', {
url: '/About',
template: '<b>This is About us</b>'
        })};
36 How can we create controllers and pass parameters in Angular UI route? myApp.config(function ($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('State1', {
            url: '/SomeURL/{Id:[0-9]{4,4}}',
            template: '<b>asdsd</b>',
            controller: function ($scope, $stateParams) {
                alert($stateParams.Id);
            }
        });
37 How to implement nested views using Angular UI route? myApp.config(function ($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state(“View”, {
            templateUrl: 'View.htm'
        })
        .state('View.SubView1', {
            template: '<b>Sub view 1</b>'
        }).state('View.SubView2', {
            template: '<b>Sub view 2</b>'
        });
});

<a ui-sref="View.SubView1" href="#View.SubView1">Sub view 1</a>
<a ui-sref="View.SubView2" href="#View.SubView1 ">Sub view 2</a>
<div ui-view></div>
38 How can we create a custom directive in Angular? app.directive('companyCopyRight', function ()
{
return
{
        template: '@CopyRight   dotnet-professional-amit.blogspot.in/'
 };
});

<div ng-controller="CustomerViewModel">
<div company-copy-right></div>
</div>
39 What kind of naming conventions is used for custom directives? camelCase
40 What are the different custom directive types in AngularJS? Element directives (E)
Attribute directives (A)
CSS class directives (C)
Comment directives (M)
myapp.directive('userinfo', function()
{
    var directive = {};
    directive.restrict = 'E';
    directive.template = "User : {{user.firstName}} {{user.lastName}}";
    return directie;
});

// Element
<userinfo></userinfo>
// Attribute
<div userinfo></div>
41 What if I want custom directives to be applied on element as well as attributes ? directive.restrict = 'EA'; directive.restrict = 'EA';
42 Can I set an Angular directive template to a HTML web page? directive.templateUrl = "/templates/footer.html";
43 Explain $q service, deferred and promises? Promises are POST PROCESSING LOGICS which you want to execute after some operation / action is completed.  Below is the angular code for the above 4 steps.
// Step 1
    function SomeClass($scope,$q) {
// Step 2 
        var defer = $q.defer();
// step 3
        var promise = defer.promise;
// step 4
promise.then(function () {
            alert("Logic1 success");
        }, function () {
            alert("Logic 1 failure");
        });

promise.then(function () {
            alert("Logic 2 success");
        }, function () {
            alert("Logic 2 failure");
        });

    }
44 What are the filters  Filters are used to modify the data and clubbed in expression or directives using a pipe character
- currency
- date
- filter
- json
- limitTo
- lowercase
- number
- orderBy
- uppercase
{{ x | currency}}
45 Custom filter Creating our own custom filter myApp.filter("toText", function()
{
 return function(value)
 {
  if(value==1){
   return "One";
  }
  else if(value==2){
   return "Two";
  }
  else {
   return "Unknown";
  }
 }
});
46 Module and controller AngularJS module is nothing but a container of all angular components like controller, services, directive, filter, config etc

Controller is a JavaScript constructor function which controls the data
module
var myApp = angular.module(‘myModuleApp’,[]);

Controller
myApp.controller(‘myController’, function($scope) 

 
}); 
47 Explain ng-app directive to implement automatic angular bootstrap
48 What are compile & link options in Custom Directives Compile
It traverses the DOM and collects all of the directives and deals with transforming the template DOM. The result is a linking function.

Link
The link function deals with linking scope to the DOM
49 What is AngularJS BootStrap Process Automatic BootStrap
Manual BootStrap
50 scopeless controller var app = angular.module("myApp"); 
app.controller("myController", function()  

    this.title = 'scopeless Controller Test'; 
    this.name = 'Anupam'; 
    this.sayHello = function()  
    { 
        alert('Hello ' + this.name); 
    } 
}); 
51 Broadcast, Emit and On Broadcast: We can pass the value from parent to child
         i.e parent -> child controller.
Emit: we can pass the value from child to parent
         i.e.child ->parent controller.
On: catch the event dispatched by $broadcast or $emit.
52 How to stop the propagation Emit : StopPropagation
BroadCast : defaultPrevented -> this approach is more logical
event.stopPropagation();

event.defaultPrevented = true; 
then logic 
53 Jquery with Angular If we working with jquery then we have to keep 2 things
1. Jquery goes and manipulate HTML DOM, it has no affect on Angular DOM
2. To work you have to update scope object and kick off the digest cycle
$scope.$apply()
54 Jasmine  Jasmine is open source javascript framework  for unit testing
55 Where to check the result SpecRunner.html describe("", function(){
   it("Must return sum of 2 integer", function(){
          expect(Add(5,6).toBe(11);
    }
}

Interview question one line on Asp.net MVC

Sl No Questions Keyword Answer Example
1 What is MVC (Model view controller)? MVC is an architectural pattern which separates the representation and user interaction. It’s divided into three broader sections, Model, View, and Controller.
2 Explain MVC application life cycle?
Creating the request object: -The request object creation has four major steps. Below is the detail explanation of the same.

Step 1 Fill route: - MVC requests are mapped to route tables which in turn specify which controller and action to be invoked. So if the request is the first request the first thing is to fill the route table with routes collection. This filling of route table happens in the global.asax file.

Step 2 Fetch route: - Depending on the URL sent “UrlRoutingModule” searches the route table to create “RouteData” object which has the details of which controller and action to invoke.

Step 3 Request context created: - The “RouteData” object is used to create the “RequestContext” object.

Step 4 Controller instance created: - This request object is sent to “MvcHandler” instance to create the controller class instance. Once the controller class object is created it calls the “Execute” method of the controller class.

Creating Response object: - This phase has two steps executing the action and finally sending the response as a result to the view

3 Is MVC suitable for both Windows and web applications? MVP 
4 What are the benefits of using MVC? There are two big benefits of MVC:

Separation of concerns is achieved as we are moving the code-behind to a separate class file.
Automated UI testing is possible because now the behind code (UI interaction code) has moved to a simple .NET class.
5 Is MVC different from a three layered architecture?
6 What is the latest version of MVC? MVC 6 is the latest version which is also termed as ASP VNEXT
7 What is the difference between each version of MVC 2, 3 , 4, 5 and 6?
8 What are HTML helpers in MVC?
9 What is the difference between “HTML.TextBox” vs “HTML.TextBoxFor”? “HTML.TextBoxFor” is strongly typed while “HTML.TextBox” isn’t Html.TextBox("CustomerCode")

Html.TextBoxFor(m => m.CustomerCode)
10 What is routing in MVC? Routing helps you to define a URL structure and map the URL with the controller routes.MapRoute(
               "View", // Route name
               "View/ViewCustomer/{id}", // URL with parameters
               new { controller = "Customer", action = "DisplayCustomer",
id = UrlParameter.Optional }); // Parameter defaults
11 Where is the route mapping code written? The route mapping code is written in "RouteConfig.cs" file and registered using "global.asax" application start event
12 Can we map multiple URLs to the same action? Yes, you can, you just need to make two entries with different key names and specify the same controller and action.
13 Explain attribute based routing in MVC? "Route" attribute  public class HomeController : Controller
{
       [Route("Users/about")]
       public ActionResult GotoAbout()
       {
           return View();
       }
}
14 What is the advantage of defining route structures in the code? public class HomeController : Controller
{
       [Route("Users/about")]
       [Route("Users/WhoareWe")]
       [Route("Users/OurTeam")]
       [Route("Users/aboutCompany")]
       public ActionResult GotoAbout()
       {
           return View();
       }
}
15 How can we navigate from one view to other view using a hyperlink? <%= Html.ActionLink("Home","Gotohome") %>
16 How can we restrict MVC actions to be invoked only by GET or POST? Decorate the MVC action with the HttpGet or HttpPost attribute to restrict the type of HTTP calls [HttpGet]
public ViewResult DisplayCustomer(int id)
{
    Customer objCustomer = Customers[id];
    return View("DisplayCustomer",objCustomer);
17 How can we maintain sessions in MVC? Sessions can be maintained in MVC by three ways: tempdata, viewdata, and viewbag
18 What is the difference between tempdata, viewdata, and viewbag? Sessions can be maintained in MVC by three ways: tempdata, viewdata, and viewbag
19 What is difference between TempData and ViewData ? “TempData” maintains data for the complete request while “ViewData” maintains data only from Controller to the view.
20 Does “TempData” preserve data in the next request also? “TempData” is once read it will not be available in the subsequent request
21 What is the use of Keep and Peek in “TempData”? If we want “TempData” to be read and also available in the subsequent request then after reading we need to call “Keep”

The more shortcut way of achieving the same is by using “Peek”. 

 @TempData[“MyData”];
TempData.Keep(“MyData”);

string str = TempData.Peek("Td").ToString();
22 What are partial views in MVC? Partial view is a reusable view (like a user control) which can be embedded inside other view.
23 How do you create a partial view and consume it? <body>
<div>
       <% Html.RenderPartial("MyView"); %>
</div>
</body>
24 How can we do validations in MVC?
25 Can we display all errors in one go?
26 How can we enable data annotation validation on the client side?
27 What is Razor in MVC? It’s a light weight view engine. Till MVC we had only one view type, i.e., ASPX. Razor was introduced in MVC 3.
28 Why Razor when we already have ASPX? In Razor, it’s just one line of code:  @DateTime.Now
29 So which is a better fit, Razor or ASPX? As per Microsoft, Razor is more preferred because it’s light weight and has simple syntaxes.
30 How can you do authentication and authorization in MVC? You can use Windows or Forms authentication for MVC.
31 How to implement Windows authentication for MVC? <authentication mode="Windows"/>
<authorization>
<deny users="?"/>
</authorization> 
32 How do you implement Forms authentication in MVC?
Step 1:

<authentication mode="Forms">
<forms loginUrl="~/Home/Login"  timeout="2880"/>
</authentication>

Step 2:
public ActionResult Login()
{
    if ((Request.Form["txtUserName"] == "Shiv") &&
          (Request.Form["txtPassword"] == "Shiv@123"))
    {
        FormsAuthentication.SetAuthCookie("Shiv",true);
        return View("About");
    }
    else
    {
        return View("Index");
    }
}

Step 3:
[Authorize]
PublicActionResult Default()
{
    return View();
}
[Authorize]
publicActionResult About()
{
     return View();
33 How to implement AJAX in MVC
34 What kind of events can be tracked in AJAX?
35 What is the difference between ActionResult and ViewResult? ActionResult is an abstract class while ViewResult derives from the ActionResult class public ActionResult DynamicView()
{
   if (IsHtmlView)
     return View(); // returns simple ViewResult
   else
     return Json(); // returns JsonResult view
36 What are the different types of results in MVC? There 12 kinds of results in MVC, at the top is the ActionResult class which is a base class that can have 11 subtypes as listed below:

ViewResult - Renders a specified view to the response stream
PartialViewResult - Renders a specified partial view to the response stream
EmptyResult - An empty response is returned
RedirectResult - Performs an HTTP redirection to a specified URL
RedirectToRouteResult - Performs an HTTP redirection to a URL that is determined by the routing engine, based on given route data
JsonResult - Serializes a given ViewData object to JSON format
JavaScriptResult - Returns a piece of JavaScript code that can be executed on the client
ContentResult - Writes content to the response stream without requiring a view
FileContentResult - Returns a file to the client
FileStreamResult - Returns a file to the client, which is provided by a Stream
FilePathResult - Returns a file to the client
37 What are ActionFilters in MVC?
38 What are the different types of action filters? 1. Authorization filters
2. Action filters
3. Response filters
4. Exception filters
39 If we have multiple filters, what’s the sequence for execution? 1. Authorization filters
2. Action filters
3. Response filters
4. Exception filters
40 Can we create our own custom view engine using MVC? Yes
Step 1: We need to create a class which implements the IView interface. In this class we should write the logic of how the view will be rendered in the render function.
Step 2: We need to create a class which inherits from VirtualPathProviderViewEngine and in this class we need to provide the folder path and the extension of the view name. For instance, for Razor the extension is “cshtml”; for aspx, the view extension is “.aspx”, so in the same way for our custom view, we need to provide an extension.
Step 3: We need to register the view in the custom view collection. The best place to register the custom view engine in the ViewEngines collection is the global.asax file
41 How to send result back in JSON format in MVC JsonResult class public JsonResult getCustomer()
{
    Customer obj = new Customer();
    obj.CustomerCode = "1001";
    obj.CustomerName = "Shiv";
    return Json(obj,JsonRequestBehavior.AllowGet);
}
42 What is WebAPI? WebAPI is the technology by which you can expose data over HTTP following REST principles
43 But WCF SOAP also does the same thing, so how does WebAPI differ?
44 With WCF you can implement REST, so why WebAPI? WCF was brought into implement SOA, the intention was never to implement REST. WebAPI is built from scratch and the only goal is to create HTTP services using REST. Due to the one point focus for creating REST service, WebAPI is more preferred. public class ValuesController : ApiController
{
    // GET api/values
    public IEnumerable<string> Get()
    {
        return new string[] { "value1", "value2" };
    }
    // GET api/values/5
    public string Get(int id)
    {
        return "value";
    }
    // POST api/values
    public void Post([FromBody]string value)
    {
    }
    // PUT api/values/5
    public void Put(int id, [FromBody]string value)
    {
    }
    // DELETE api/values/5
    public void Delete(int id)
    {
    }
45 How can we detect that a MVC controller is called by POST or GET? Request.HttpMethod property public ActionResult SomeAction()
{
    if (Request.HttpMethod == "POST")
    {
        return View("SomePage");
    }
    else
    {
        return View("SomeOtherPage");
    }
}
46 What is Bundling and Minification in MVC? Bundling and minification helps us improve request load times of a page thus increasing performance.
47 How does bundling increase performance? Web projects always need CSS and script files. Bundling helps us combine multiple JavaScript and CSS files in to a single entity thus minimizing multiple requests in to a single request

Can be checked via fiddler or developer tool
48 How do we implement bundling in MVC? public  class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/Scripts/MyScripts").Include(
           "~/Scripts/*.js"));
        BundleTable.EnableOptimizations = true;
    }
}

<%= Scripts.Render("~/Scripts/MyScripts")  %>
49 How can you test bundling in debug mode? BundleTable.EnableOptimizations = true;
50 Explain minification and how to implement it Minification reduces the size of script and CSS files by removing blank spaces , comments etc.  // This is test
var x = 0;
x = x + 1;
x = x * 2;

var x=0;x=x+1;x=x*2;
51 How do we implement minification? steps to implement bundling and minification are the same.
52 Explain Areas in MVC? Areas help you to group functionalities in to independent modules thus making your project more organized
53 Explain the concept of View Model in MVC? A view model is a simple class which represents data to be displayed on the view.
54 What kind of logic view model class will have?
55 How can we use two ( multiple) models with a single view?
56 Explain the need of display mode in MVC?
57 Explain MVC model binders? Model binder maps HTML form elements to the model. It acts like a bridge between HTML UI and MVC model
58 Explain the concept of MVC Scaffolding? Scaffolding is a technique in which the MVC template helps to auto-generate CRUD code. 
59 What does scaffolding use internally to connect to database? It uses Entity framework internally
60 How can we do exception handling in MVC?
61 How can you handle multiple Submit buttons pointing to multiple actions in a single MVC view?
62 What is CSRF attack and how can we prevent the same in MVC?