Dot Net Core and Azure Interview Questions
Dot Net Core and Azure Interview Questions
Dot Net Core and Azure Interview Questions
1. What is middleware?
It is a software component that is assembled into the application pipeline to handle the HTTP
Request and Response. Each middleware component perform the task
1. to pass the HTTP Request to the next component in the pipeline. This can be
achieved by calling the next() method within the middleware.
Can perform work before and after the next component in the pipeline.
Thare are so many build-in middleware components available in .net core that can be use
directly.
Middlware can be configured in configure() method of startup class. This is the class that is
going to run when the application starts.
{
CreateWebHostBuilder(args).Build().Run();
WebHost.CreateDefaultBuilder(args)
.UseStartup<TestClass>();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseCors(c =>
{
c.AllowAnyOrigin();
c.AllowAnyHeader();
c.AllowAnyMethod();
});
}
app.UseRouting();
app.UseMiddleware<LoggingMiddleware>();
app.UseAuthentication();
app.UseAuthorization();
In ASP.NET Core, Request delegates are used to build the request pipeline i.e. request delegates
are used to handle each incoming HTTP request. In ASP.NET Core, you can configure the
Request delegates using the Run, Map, and Use extension methods.
13. what is Difference between MVC Routing and .Net core Routing mechanism
I asp.net MVC routing we can define conventional base routing in RouteConfig.cs class
which id define in App_Statup folder and in Asp.net core MVC routing template is define
configure method of Startup class. Use the middleware service to configure the
conventional base routing in .net core.
14. Explain how you implemented Authentication and Authorization in your project
In my current project we configure Authentication and authorize middleware in
configure class. In ConfigureServices method of Startup.cs. create an Authentication
Middleware Services with the AddAuthentication and AddCookie method.
Authentication scheme passed to AddAuthentication sets to the default authentication
scheme for the app. CookieAuthenticationDefaults.AuthenticationScheme provides
“Cookies” for the scheme. In AddCookie extension method, set the LoginPath property
of CookieAuthenticationOptions to “"/Login”. CookieAuthenticationOptions class is used
to configure the authentication provider options.
services
.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.LoginPath = "/Login";
options.LogoutPath = "/Login/Logout";
options.AccessDeniedPath = "/";
});
In Configure method of Startup.cs, call UseAuthentication and UseAuthorization method before
calling the endpoints.
After clicking login button it will call the login controller and check input user name password
and expiry date if it is valid then login successfully and stored details in cookies else throw the
exception.
Dependency Injection is a Design Pattern that's used as a technique to achieve the Inversion of
Control (IoC) between the classes and their dependencies.
ASP.NET Core comes with a built-in Dependency Injection framework that makes configured
services available throughout the application. You can configure the services inside the
ConfigureServices method as below.
services.AddScoped();
A Service can be resolved using constructor injection and DI framework is responsible
for the instance of this service at run time. For more visit ASP.NET Core Dependency
Injection
17. Describe the Service Lifetimes.
When Services are registered, there is a lifetime for every service. ASP.NET Core provide
following lifetimes.
ASP.NET Core allows to specify the lifetime for registered services. The service instance gets
disposed of automatically based on a specified lifetime. So, we do not care about the cleaning
these dependencies, it will take care by ASP.NET Core framework. There is three type of
lifetimes.
Singleton: In this case, the IoC container will create and share a single instance of a
service object throughout the application’s lifetime.
Transient: In this case, the IoC container will create a new instance of the specified
service type every time you ask for it.
Scoped: In this case, the IoC container will create an instance of the specified service
type once per request and will be shared in a single request.
class Test{
// requires using Microsoft.Extensions.Configuration;
private readonly IConfiguration Configuration;
public TestModel(IConfiguration configuration)
{
Configuration = configuration;
}
// public void ReadValues(){
var val = Configuration["key"]; // reading direct key values
var name = Configuration["Employee:Name"]; // read complex values
}
}
Default configuration provider first load the values from appsettings.json and then from
appsettings.Environment.json file.
Environment specific values override the values from appsettings.json file. In development
environment appsettings.Development.json file values override the appsettings.json file
values, same apply to production environment.
You can also read the appsettings.json values using options pattern described Read values
from appsettings.json file.
21. Can ASP.NET Core application work with full .NET 4.x Framework?
Yes. ASP.NET core application works with full .NET framework via the .NET standard library.
-------------------------------------------------------------
22. What is the use of "Map" extension while adding middleware to ASP.NET Core
pipeline?
It is used for branching the pipeline. It branches the ASP.NET Core pipeline based on request
path matching. If request path starts with the given path, middleware on to that branch will
execute.
app.Map("/path1", Middleware1);
app.Map("/path2", Middleware2);
….
….
services.AddSession();
services.AddMvc();
….
….
app.UseSession();
….
….
24. What are the various JSON files available in ASP.NET Core?
There are following JSON files in ASP.NET Core :
global.json
launchsettings.json
appsettings.json
bundleconfig.json
bower.json
package.json
25. What is the purpose of the wwwroot folder in Asp.net Core?
The wwwroot folder contains all static files like CSS, Images, JavaScript, Html files which are
served directly to the clients.
Note: While calling the next method from any custom middleware components, we need to
pass the context object
Zero Garbage collectors is the simplest possible implementation that in fact does almost nothing. It
only allows you to allocate object because this is obviously required by the Execution Engine. Create
object are never automatically deleted and theoretically, no longer needed memory is never reclaimed.
Varsha
The layouts are like the master pages in Webforms applications. The common UI code, which can be
used in many views can go into a common view called layout.
8. What are lifespans of Service how to Set that explain in detail with example-Azure
9. How you Monitor your Application Performance(Explain Azure App Insight )
10. How you Handled Exceptions in .net core(Explain Log file implementation and
Appinsights)
11. How you manage App security(Explain Azure Keyvault Service )
15. Explain Which pattern you used in your project and why
Azure Interview Question
1. Explain Azure Pricing structure
2. Which Azure Services you have used in your project
3. Explain what is Azure Keyvault how to implement it in our application
4. What is Application Insights and How to use it in our App
5. What is Azure Active directory Authentication
6. How Token generates in AAD Auth
7. Explain the flow from User request to response if we are using AAD app
8. How to create AAD App in Azure portal
9. How to manage Users
10. How to Implement Role Based authentication
11. Steps to implement AAD auth in Application
12. How to manage the Token at server side
13. In which file we need to add Keyvault configuration settings
14. What is Blob Storage why to use it
15. What is meant by PaaS, SaaS, and IaaS?
16. How to connect to Azure SQL Server
Repository design patter is abstraction layer between data access layer and business layer. a
repository is nothing but a class defined for an entity, with all the possible database operations.
For example, a repository for an Employee entity will have the basic CRUD operations and any
other possible operations related to the Employee entity.
In a single thread application, all the logic or code present in the program will be executed by a
single thread only i.e. the Main thread. For example, if we have three methods in our
application and if all these three methods are going to be called from the Main method. Then
the main thread is responsible to execute all these three methods sequentially i.e. one by one.
It will execute the first method and once it completes the execution of the first method then
only it executes the second method and so on.
How to solve the single threaded application problem?
Asynchronous Programming in C#
A task in C# is used to implement Task-based Asynchronous Programming and was introduced
with the .NET Framework 4. The Task object is typically executed asynchronously on a thread
pool thread rather than synchronously on the main thread of the application. A task scheduler
is responsible for starting the Task and also responsible for managing it.
Tasks in C# is nothing but an operation or a work that executes in asynchronous manner.
in-fact the Task Parallel Library which is known as TPL is based on the concept of Tasks.
n C# Task is basically used to implement asynchronous programming model, the .Net runtime
executes a Task object asynchronously on a separate thread from the thread pool.
Cognizent
1. Difference between ActionResult and ViewResult