Tuesday, July 24, 2018

Interview

1.What is Node.js
2.Difference between bootstrap 3 and bootstrap 4.
3.Polymorphism and encapsulation in JavaScript.
Ans : https://www.javatpoint.com/javascript-oops-polymorphism
https://medium.com/javascript-scene/encapsulation-in-javascript-26be60e325b4
4.Common files in distrbution package in angular Js
5.How can we create singleton in angular
  There are two ways to make a service a singleton in Angular:  
  Set the providedIn property of the @Injectable() to "root".
  Include the service in the AppModule or in a module that is only imported by the AppModule
  
6.If starting page of application is slow then how you will check the performance.
Ans : Check if lazy loading applied or not. To make it fast lazy loading should be applied.

7.How will you check memory leak in your application in angular
open the Chrome Dev Tools, open the panel on the right and click on More Tools > Performance Monitor.
8.What is new in angular5
9.What is EventEmitter?
EventEmitter used in components with the @Output directive to emit custom events synchronously or asynchronously, and register handlers for those events by subscribing to an instance
10.Which one is better to write filter logic client side or server side if records are 1000.
Ans : Server side.
11.How will you fetch data in one go or in parts.
Ans : in parts
12.If some data is coming from an api where it get stored? Is it stored somewhere? (Browser, PC).
Ans : No where
13.What is benefit of linting?
Ans : A linter is a program that can analyze source code in a particular programming language and flag potential problems like syntax errors, deviations from a prescribed coding style, or using constructs known to be unsafe. For example a JavaScript linter would flag the first use of parseInt below as unsafe:

// Unsafe without a radix argument
var count1 = parseInt(countString);

// Safe because a radix is specified
var count2 = parseInt(countString, 10);

14.Difference between JIT and AOT?
  Just-in-Time (JIT), compiles your app in the browser at runtime.
Ahead-of-Time (AOT), compiles your app at build time on the server.
JIT compilation is the default when you run the ng build (build only) or ng serve (build and serve locally) CLI commands. This is for development.

For AOT compilation, include the --aot option with the ng build or ng serve command. Another ways is using --prod which by default production mode is configured in Angular.json with AOT is set to true
15.What does CLI do?
Ans: CLI gives command to scafolding, create component create module.

16.Tell me some commands for CLI?
Ans : ng build, ng g c cusotm, ng g s user
17.Who does minification and bundling? What is the benefit?
Ans : Webpack
18.Why the build generated by AOT is faster?
19.How the typescript get transplied? What is the output?
Ans :

20.What is benefit of SPA?
Ans:
1. Only data comes from server instead of complete html
2. Easy to deploye in comparision of Server side application.

3. Fast 
  Battery reusability
Optimization
Client-side rendering
User experience
Easy debugging
Performance
Less complex implementation
Better caching
Better SEO optimization
Disadvantages of Single-page Apps
There are also some disadvantages to using single-page apps:

Single-page apps use JavaScript, so it can be difficult to trace errors.
Users need to turn on JavaScript in their web browser or the application won’t work.
Memory leaks may result in a performance dro .
Single-page apps are not suitable for enterprise-based applications, only for small and mid-size applications.
They have terrible maintainability due to using third-party plug-ins.
  

21.How will you start developing angular application?
22.We have requirement for TAB and Desktop to run application so what will you do in bootstrap?
And : Tab is medium and Desktop is large device

23.What will you do to support SAAS in angular?
Ans :  At the time of application creation it will ask you what you want to use css,saas,scss,less

24.How the web server will know which file is the entry file of application.
Ans Location Strategy
25.How will you secure api ?
Ans: Using token.

26.Whihc architechture angular follows?
Ans : There was much confusion about whether Angular was really Model-View Controller (MVC) or Model-View-ViewModel (MVVM) . In reality, it was neither! Rather, Angular follows a component-oriented architecture. Having said that, Angular does share some of the concepts of both MVC and MVVM.
Ans : https://www.htmlgoodies.com/javascript/the-model-view-viewmodel-pattern-and-angular-development
27. Post is cachable or not?
Ans
"Responses to POST method are not cacheable, UNLESS the response includes appropriate Cache-Control or Expires header fields."

So, YES, you can cache POST request response but only if it arrives with appropriate headers. In most cases you don't want to cache the response. But in some cases - such as if you are not saving any data on the server - it's entirely appropriate.


Note, however many browsers, including current Firefox 3.0.10, will not cache POST response regardless of the headers. IE behaves more smartly in this respect.


Cache-Control: max-age=3600

A PUT request cannot be cached. Moreover, it invalidates cached data for request to the same URI done via HEAD or GET:

PUT /pageX.html HTTP/1.1
(…)

200 OK
(…)
A specific Cache-Control header in the response can prevent caching:

GET /pageX.html HTTP/1.1
(…)

200 OK
Cache-Control: no-cache

(…)

ISHIR

1.How will you check number of users currently accessing your website?
2.How will you prevent DDOS attack?
Ans : A distributed denial-of-service (DDoS) attack is a malicious attempt to disrupt the normal traffic of a targeted server, service or network by overwhelming the target or its surrounding infrastructure with a flood of Internet traffic. DDoS attacks achieve effectiveness by utilizing multiple compromised computer systems as sources of attack traffic. Exploited machines can include computers and other networked resources such as IoT devices. From a high level, a DDoS attack is like an unexpected traffic jam clogging up the highway, preventing regular traffic from arriving at its destination.
Ans : https://www.guru99.com/indexing-in-database.html
https://www.cloudflare.com/en-in/learning/ddos/what-is-a-ddos-attack/
3.What is the return type of Result Filter?
Ans : Return type is void. There are two methods public void OnResultExecuted(ResultExecutedContext filterContext) public void OnResultExecuting(ResultExecutingContext filterContext)
4.How many types of filter in MVC5?
Ans : Four types.
https://interview-preparation-for-you.blogspot.com/search?q=Filter
5.What is benefit of attribute routing?
Ans : Helps developer in the debugging / troubleshooting mode by providing information about routes.
Reduces the chances for errors, if a route is modified incorrectly in RouteConfig.cs then it may affect the entire application's routing.
May decouple controller and action names from route entirely.
Easy to map two routes pointing to the same action.
https://interview-preparation-for-you.blogspot.com/2018/01/attribute-based-routing.html
6.What is WCF security?
Ans : https://interview-preparation-for-you.blogspot.com/2017/05/wcf-interview-questions.html
7.When will you use SOAP and when rest?
Ans : https://interview-preparation-for-you.blogspot.com/2018/11/difference-between-wcf-and-web-api.html
8.Store procedure optimization technique?
Ans : https://interview-preparation-for-you.blogspot.com/2021/05/procedure-optimization-technique.html
9.What is difference between CTE and temp variable?
Ans : https://interview-preparation-for-you.blogspot.com/2018/04/cte-vs-temp-table.html
10.There is a query we have used 20-30 joins? Is it good to write so many joins?
Ans : No
11.We have two columns first name and last name. One indexing is applied on first name. and we have a quyery to searching last name
So do we get the benefit of indexing?
Ans : No
12.What is primary index and secondary index in a table?
The secondary Index in DBMS can be generated by a field which has a unique value for each record, and it should be a candidate key. It is also known as a non-clustering index. This two-level database indexing technique is used to reduce the mapping size of the first level. For the first level, a large range of numbers is selected because of this; the mapping size always remains small.
Ans : https://www.guru99.com/indexing-in-database.html
13.How will we check execution time of store procedure?
Ans Using SQL Optimizer
14.In a controller we have dependency injection so how will you call controller method without using IOC container.
15.What is elastic IP in AWS?
16.Can we use mongodb in RDS in AWS
17.Can we have contructor in static class.
Ans : No, It can have only static constructor. 18.When we have object in gen 2 in GC
19.How will you implement finalize and why?
Ans: Destructor method is converted in finalize method,
If there are some unmanaged code used in application than we use Finalize to free the memory.If no unmanaged code used than no need to use Finalize method
20.difference between ref and out
21.what is IEnumerable and IEnumerator
22.var vs dynamic?
23.Real example of Interface and Abstract Class.
24.Router in Angular.
25.life cycle hook in angular?
26.lazy loading in angular?
27.Component communication in angular
28.Benifit of private constructor?

Thursday, July 12, 2018

Model Binding .Net Core

Model binding is the process whereby the MVC or WebApi pipeline takes the raw HTTP request and converts that into the arguments for an action method invocation on a controller.




It is important to note that if the model binders fail to bind the parameters for some reason, they will not throw an error, instead you will receive a default object, with none of the properties set, which is the behaviour we showed earlier.


In order to bind the JSON correctly in ASP.NET Core, you must modify your action to include the attribute [FromBody] on the parameter. This tells the framework to use the content-type header of the request to decide which of the configured IInputFormatters to use for model binding.



So just always include [FromBody]?


So if you were thinking you can just always use [FromBody] in your methods, hold your horses. Lets see what happens when you hit your new endpoint with a x-www-url-formencoded request:
appStatus=true;

Oh dear. In this case, we have specifically told the ModelBinder to bind the 
body of the post, which is FirstName=Andrew&LastName=Lock&Age=31, using an IInputFormatter. Unfortunately, the JSON formatter is the only formatter we have and that doesn't match our content type, so we get a 415 error response.


In order to specifically bind to the form parameters we can either remove the FromBody attribute or add the alternative FromForm attribute, both of which will allow our form data to be bound but again will prevent the JSON binding correctly.


https://andrewlock.net/model-binding-json-posts-in-asp-net-core/

Followers

Link