hey my name is happy and in this video I'm going to share with you the 30 most important questions asked in totet core interviews here is the list of questions which we will discuss in this you video you can see almost all questions are covered here if you are preparing for net interviews then you can like And subscribe this channel for upcoming net interview videos so let's start what is net core this is the first and very basic question in net core and the definition is net core is completely a new framework which is a free and open- Source platform developed and maintained by Microsoft let's see this diagram here you can see NET Framework and net core are two different frame Frameworks mono for zaran is also a different framework it is used for developing mobile applications all this framework shares some common standard libraries which we call as net standard library next question what are the advantages of totet core over totet framework let's try to answer and memorize the advantages one by one First Advantage is net cor is cross crossplatform which means it can be run in multiple operating systems like Windows Linux and Mac but NET Framework can only be run in Windows operating system second Advantage is it is completely open source which means it is free to use easily modifiable and easily distributable whereas do NET Framework is not an open source third Advantage is net core is easy to integrate with modern UI Frameworks like angular react and fugs Net Framework can also be integrated with these UI Frameworks but comparatively it is easy to integrate them with net core next advantage of net core is hosting it can be hosted in multiple servers like castl I and engine we will discuss castral web server in upcoming questions next Advantage is net core have built in dependency injection which enables net core applications to achieve Loosely coupled design if you are new to independency injection and Loosely coupled design then don't worry I will explain these Concepts in upcoming questions and one more Advantage is net course supports multiple Ides like Visual Studio visual studio for mac and visual studio code whereas NET Framework supports only one ID and that is Visual Studio next question is explain the default project structure in asp.net core application this question is not directly asked in interviews but one must aware about the default files in asp.net core application in the diagram you can see by default we have four to five important files and the files are app settings. Json program.cs startup.cs and the directory www root ww root is used to store static files of the application like JS CSS and images next question is explain default project structure in asp.net core application this question is not directly asked in interviews but one must be aware about the default files in asp net core application in the diagram you can see by default we have four to five important files and directories in asp.net core first one is WW root which is basically used to store static files of the application like JS CSS and images second file is program.cs file which is basically the entry point of the application third file is startup.cs file which is used to configure services and request pipeline of the application fourth and the last file is app settings. Json which is used for saving configuration settings like database connection string and other things in the application we will discuss all these files in details in upcoming questions next question is what is the role of program.cs file in net core program.cs file is the entry point of application via main method which means whenever any request will come from any client then the main method is the first point of contact for it now this main method will build the host server like the castal and I servers with the help of this build method then the run method will send the request to the startup class here we are calling startup class with the help of create host Builder method and Lambda expression if you have not worked in Lambda expression earlier then don't worry just remember that here we are calling the startup class and that's it next question is what is the role of starter. Cs file in net core this is a very important file in asp.net core first thing is you must know the start in flow in esp.net core application here in the diagram you can see the flow program. CS file is the entry point and then it is redirect the request to the startup. Cs file for configuring the services and request pipeline now here you can see the code block of startup.cs file here we have the startup Constructor which is used used for setting the configuration related things with I configuration interface second and third methods are configured services and configure these methods we will discuss in detail in next question so basically startup class is used to configure service and to handle the request pipeline next question is what is the role of configure services and configure method here in the screen short you are seeing two methods configure services and configure in the startup class first is the configure Services method which will execute before the configure method you can add any number of services inside this method but whether the service will execute or not that depends whether you have used this services in your application or not for example in the screenshot you can see we have added one services and that is ADD controllers with views which will help controllers to run in this application but if client request is an HTML page then this service will not be required so that's why configur services are optional while execution it is like adding services but executing them is depend on the type of request received by the server on the other hand configure method will configure the request pipeline what is the request pip line request pipeline meaning is all the methods written over here this one this one AB root use authorization and user endpoints these methods will execute in the same sequence and they are the part of the request pipeline so every request will process all these methods therefore they are not optional these methods are also called middleware components so basically configure method is specify how the app responds to http request and response next question is what is dependency injection in asp.net core or how can we inject the service dependency into the controller this is the most important question in the asp.net core if you want to give a on line answer then you can just say to the interviewer dependency inje ction helps to create Loosely coupled design of the application now I will explain what is Loosely coupled design and how to achieve it by dependency injection in asp.net core let's say you are working for a client application and there you have 100 controllers in your application first controller second controller third controller fourth and so on up to 100 controllers like this now in the screenshot you can see you are creating object of math student class in order to get the functionality get a student count for this you will create the object of the math student class in all the 100 controllers right now after some months your client will ask you to replace this math student with science student for that you will add a new class science student like this and you will replace the math student code with signs a student in all the controllers now you can see it is very much difficult to replace this in all the 100 controllers because then there are chances that you will miss some controllers and therefore it will led to an error that is called tight coupling where one class object are directly created in another class which is not good for big complex applications now in order to resolve this and to avoid creation of objects in controllers we will create a loely couple design for that first create an interface I student which only contains Declaration of the method get student count remember interface can only contain declaration no definition then inherit this interface in math student and science student class like this next thing is to go to Startup class and add I student type math student with the help of extension method add single ton like this shown in the screenshot I will discuss this add Singleton method in another question but here you can just understand that this is used to register science student class of I student type sorry math student class of I student type now change the code of code of your controllers like this you can see that both these controllers have same code and there is no object creation of any specific class and the dependency of I student type is passed through Constructor in this controller not tomorrow you want to replace math student with science student class then simply replace math student with science student in configure Serv service at just one place and that is in the startup class like this see here we have replaced math student with science student then all the controllers in the application will start using science student method instead of math student without any modification in the controllers and that is automatically so that is how we decoupled the application and created a Loosely coupled design this is called buildin dependency injection in asp.net core also so this is also what we call loely couple design I think with this explanation you are quite clear that we are avoiding to create the object in the controller itself because otherwise it will create a tightly coupled design which is not desirable next question is describe the service lifetimes in p.net core or what is the difference between ADD Singleton ad scoped and add transient this is again a very important question and asked in many interviews basically service lifetime describe for how long the instance of any class will persist let me give you an example suppose in your application you have written a class logger which opens a text file and logs every exception in it to make it effective what you will do once a request will arrive you will write the code to open the text file and then write the exception correct but for any subsequent request or any other request or any next request you will you will not want to open the text file again rather you just want to use the same open file and just append the new error this will improve the performance it will avoid the reopening of text file again and again so here you can use this add single ton so this add Singleton method in this add Singleton method it only will create only one instance and this instance will be shared by all the requests of the in the application not creating the same in same class instance for different requests so here in the diagram also you can see that single instance is used by all the other requests on the other hand the second type of method is ADD scoped sometimes you want single instance for just a single request so in a single request the instance will be shared but the other request will not share that instance to achieve this you can use add a scoped extension method like this here in the diagram you can see s HTP request 1 is using scoped instance and HTTP request 2 is using different scoped instance that is ADD scoped the last one is ADD transient which means every time a new instance is created whenever it is required it is not shared by different request and not even inside the same request so here we are not sharing the instance at all this is called at transient next question is what is Middle wear as you can see a middle weer is nothing but a component that is executed on every request in the asp.net core application so all these are middle Wares we set up middleware in asp.net by using the configure method of our startup class all these methods inside the configure method like use static files use routing use authorization are middleware components which are the part of the request pipeline so every time a request will come to the server all these methods will execute in the same sequence that in which that are mentioned what is castral or what is in process and out of process hosting before understanding castral one must understand in process and out of process hosting here you can see inprocess hosting is related to IIs in this only one web server is used for hosting and that is I and the name of the process is w3wp.exe the other type of Hosting is outof process hosting in which the process name is net .exe and it is of two types in first the asp.net core uses only castl as the hosting server in second type is and castl both are used where I is used as reverse proxy server by default asp.net core uses out of process hosting so in order to make it in process one has to to set the value of ASP net core hosting model property to in process in the project file like this shown in the screenshot so now you know what is castal is castal is a lightweight web server or asp.net core application next question is what is the difference between castrell and IIs here you can see the difference castl is a lightweight web server used for hosting whereas IIs is a complete web server which is also used for hosting but it can perform complex operations which castal cannot lightweight means some functionalities like load balancing are not available in castal but it is available in IIs second difference is castal is crossplatform and can be used with other web servers like is engine X and Apachi but I can only run in Windows next difference is Cal is open source like net core but I is not open source like NET Framework next question is what is request delegate what are run use and map methods this is a very very important question and here is the answer if you know the details of request delegates then it is great but if you don't know then no problem still you can answer this question like this request delegates handle each HTTP request and are used to build pip request pipeline by using run map and use extension methods now in the diagram you can see we have three middle wees this is a example I'm giving to show you how this run use and map methods work so here in the diagram you can see we have three middle be we want to execute them one by one and then at middle we 3 we want to stop the ex execution and send the response back so in Middle wear 1 and two we will use use method which is basically used when there is a need to execute next method of next middle Weare so here after middle Weare 1 we want to execute the middle Weare 2 and after middle Weare 2 we want to execute the method of middle Weare 3 so therefore we will use use method here and then in middleware 3 we will use run method what it will do it will terminate the execution as this is the last middle Weare in the pipeline so that is the difference use will execute the next middleware while run will terminate the middleware execution what is map method it execute the middle we based on the URL request by requested by the user so it will match the URL structure with the middle wear and then execute the same method of the middle Weare that is the map method next question is what is host in asp.net core the host configures a server like castal or is and a request processing pipeline in the screenshot you can can see the create host Builder method called inside the main method here the build method will build the host of the application whether it is IIs Cal or any other web server then the next run method will execute the next method in the middleware pipeline which is the startup here so after this building the host it will execute the run here Lambda expression is used to pass the function as a parameter and then call the startup class but if you have not worked in Lambda expression earlier then don't worry just remember that here we are calling the startup class and that's it what are the various techniques to save configuration settings in asp.net core to save configuration settings like database connection string in asp.net core we can use various techniques here first is app settings. Json file which is the default technique second is azure key vault which is mostly used when the application is hosted in Azure Cloud third Technique we can use is setting the environment variables another technique is inmemory net objects then one more technique is command line arguments and the last one is custom providers how out of these techniques the first two app settings. Json and Azure keyal are the mostly used techniques for saving the configuration in the asp.net core next question is how rooting Works in asp.net core rooting is used to handle incoming HTTP requests for the app based on the URL so here you can see the URL a sample ER here home is the controller index is the action method and 100 is the ID parameter value in the code snapshot you can see how the default routing has been set inside the use endpoints method in the configure method so this is how the routing works it is very much similar to the asp.net MVC next question is explain attribute routing in asp.net core attribute based routing is the ability to manipulate the behavior of URL by using the root attribute for example you want to redirect the user to index method when user will type the new index like this in the URL section for this you have to use root attribute and you can can set the behavior like this here you are manipulating the default behavior of the URL so when the U URL is new index then it will check here the new index value of the root and then it will redirect to the index method describe the complete request processing pipeline for asp.net cor MVC here you can see the flow of request in asp.net core MBC HTTP request will start from middleware then it goes for routing then the controller is initialized then action method is executed and then the view result is executed after which view result renders as the response to the browser so this is the request processing pipeline for asp.net core MVC next question is can asp.net core application work with asp.net 4.x framework or we can say can net core application can work with NET Framework the one word answer is yes asp.net core application can work with NET 4.x Framework next question is what is meta package here is the screenshot you can see a package named microsoft. ASP aspnetcore DOA this is the meta package in asp.net core application it is automatically added in the application by the asp.net for framework this package alone will include all these dependencies like Microsoft a. ASP netc cor. Diagnostics and microsoft. ASP netcor do hosting routing as integration tests and others it helps to do faster development as it do not require to include the individual asp.net core packages next question is how asp.net cor Ser static files asp.net code templat provide a root folder in WW W root form which contains all the static files to be served to the client then you app.use static files method inside the configure method of a startup class enables the static files to be served to client that's it what are the various Json files available in asp.net core the first file available is global. Json where you can Define the solution level settings for example your application name and version second file is launch settings. Json here you can set the environment variables in this file for example set development or production environment in this file third and very important file is app settings. Json here you can set configuration settings like database connection is string and other things it is similar to web.config in asp.net next file is bundle config.js which is used to configure the bundling and minification for the project of for the project files of CSS and JS files and at last there is project. Json file which is used for storing all project level configuration settings for example the version of the dependencies next question is what is net standard net standard is not a framework net standard defines a set of apis that the platform must Implement to be compliant with net standard which means it is a set of rules or Library which if any framework will follow then it is compliant with net standard in the diagram you can see that NET Framework and net core and mono for Zarin follow follow that. net extended rules next question is what are razor pages in net core like MVC there is one more development model which is supported by net core and that is Razor Pages razor Pages follow a page centc development model just like esp.net webforms it supports all the features of asp.net core in the diagram you can see a request will come and based on the page name in the URL it will be redirect to the Razer page how to use dependency injection in views in asp.net core for this first you must know how dependency injection works for controller then this can be the next question so let's take an example suppose we have ai student interface with math student class which implements that interface now we will configure this service in the configure method of startup class like this up to here we already know how to use this with controllers but suppose we want to display this student count directly on the The View so for this we will use inject directive here you can see the inject directive in the screenshot so the on line answer is a service can be injected into a View using the inject directive as shown in the screenshot of a view here what is custom middle Weare how to add custom middleware in asp.net core so middleware are nothing but basically a set of blocks which execute for every request so here you can see we have these number of middle wees in our application you can remove them add them but if you are adding here they will be executed in the sequence and they will definitely execute they are not optional now to add a custom middleware just right click on the project and you can add middleware do CS class file like any other class file in the project here is the screenshot of custom middleware this is automatically generated by the net core do not worry about the request delegate as we will discuss this in another question and here whatever your functionality you want to execute in this middle bear you should add that functionality inside this invoke method here you can add that functionality and then finally add that method in the configure method of the startup class like this so here you can see the configure method and here we are adding that middle Weare in the startup class of startup class of our application this is how we can add the middlee class in our application explain session and State Management in asp.net core here are the statement techniques used in asp.net core most of them are similar to asp.net MVC here is the first one which is cookies cookies is store data in the user browser browser send cookies with every request second is session session State helps in transferring data between different pages it takes the help of cookies for this purpose third is temp data in asp.net MVC core application temp data is used to transfer data from controller to view next is query string it is used to transfer data by appending the URL of the request and the data is limited because query string has limited amount has a limited length then the next is hidden Fields hidden fields are used to process data in same page during post packs we will not discuss all these estate management techniques in detail as it will take lot much time then but you can explore this in detail uh on Google on or on other websites next question is explain model validation in asp.net core in asp.net core model valid validation can be done by using data annotation technique here you can see the name space system. component model. dat annotation it is used to set the required attribute validation at the top of the name property and therefore it will not accept any null or blank value in it in the example you can see mobile property does not have required attribute that means it can accept the blank value so that simple it is with the help of data annotations next question is how to handle errors in asp.net core in asp.net core error handling for development and other environments can be set in configure method of startup.cs class in the code screenshot of configure method if the value of environment. is development is true and whole state stack Trace information will be displayed in the exception page but if it is false then you can customize the exception page in the else part if you want to display any custom error page in production environment then you can also replace this code with your custom code here you can see the EnV do is development method will check the ASP net core uncore envir uh environment value in launch. Json file launch settings. Json file you can set it to production environment if it is the production environment right now it is development and the file it is is launch settings. Json file next question is how to enable session in asp.net core it's quite simple the middle Weare for the session is provided by the package microsoft. ASP netc core. session here you can add add session service in the configure Services method and then add the middle bear component app. use session in the configure method of startup class it will enable session in asp.net core that's it next question is explain model binding in asp.net core model binding Maps data in an HTTP request to controller action method parameters let's try to understand this with the help of a simple example suppose you have the following action method get by ID now a user will hit this URL what will happen next model binding will find the first parameter of get by ID and integer Name ID which is here then it will look through the available sources in the HTTP requests and finds id2 in the root data so it will find this then it will convert this string 2 into integer 2 this conversion is automatic and it will done by the model bending only so it is one of the benefit of model bending so here you can see if there is any Boolean conversion data type conversion that is automatically done by model binding so now you can understand how model Bing is making the things simple for URL parameter matching with the parameter inside the action method