0% found this document useful (0 votes)
8 views

NET Interview Prep

.NET is a framework that simplifies application development with pre-built tools. .NET Core offers cross-platform capabilities and better performance compared to the traditional .NET framework, while also supporting microservices and cloud deployment. Key concepts covered include configuration management with appsettings.json, Entity Framework Core approaches, LINQ, and various aspects of MVC architecture, including action filters, middleware, and dependency injection.

Uploaded by

Ishan Bhatt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

NET Interview Prep

.NET is a framework that simplifies application development with pre-built tools. .NET Core offers cross-platform capabilities and better performance compared to the traditional .NET framework, while also supporting microservices and cloud deployment. Key concepts covered include configuration management with appsettings.json, Entity Framework Core approaches, LINQ, and various aspects of MVC architecture, including action filters, middleware, and dependency injection.

Uploaded by

Ishan Bhatt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

.

NET Interview Prep Links

Framework: It is like a pre-built structure or a set of tools that helps developers to build
applications more easily. It provides a foundation with ready-to-use components, so
developers don’t have to start everything from scratch.

.NET and .NET Core

Difference between .NET core and .NET framework


https://radixweb.com/blog/net-core-vs-net-framework
• .NET Core apps are cross-platform and ‘build once run anywhere’ (works on
different OS like Windows, Linux, Mac etc.) whereas .NET framework apps run
on Windows.
• .NET Core better than .NET framework in terms of performance and scalability.

NOTE: ASP .NET is a part of the .NET framework.

Advantages of .NET core over .NET framework


• Cross-platform
• Allows usage of microservices
• High performance apps
• Easier cloud deployment

appsettings.json file
https://dotnettutorials.net/lesson/asp-net-core-appsettings-json-file/

• Provides a structured way to define configuration settings like db connection,


authentication settings, external API URLs
• ASP .NET Core also supports environment-specific configuration files (eg:
appsettings.Development.json, appsettings.Staging.json,
appsettings.Production.json). Depending upon app’s environment, these files
override the basic settings in appsettings.json
JWT Authentication and Authorisation
https://www.telerik.com/blogs/asp-net-core-basics-authentication-authorization-jwt

Entity Framework (EF) Core

Code first vs DB first approach


Code first: Classes are created first or code is written first, based on that, DB and tables
are created using migrations.
DB first: EF Core creates DBContext and Domain classes based on the existing database
schema.

Migrations and Seed Data


Migrations: Process allowing developers to version and manage changes in the
database schema.
Seed Data: Process of prepopulating a database with initial or default data during the
database creation or migration process.

LINQ (Language Integrated Query)


It is a powerful query language introduced by Microsoft that allows developers to
query collection of data in a more readable and concise manner.
• LINQ can be used for variety of data sources like: Objects, Entities, XML etc.
• Ways of

Questions from YT video:


1. Diff b/w value type and reference type?
Primitive datatypes like int, float etc. are value type and structures like class,
interface etc. are reference type.

2. Diff b/w abstract class and interface?


Abstract class is generally used to define base class, which are inherited by
others and the methods are both declared and defined in the abstract class.
Interface only declares the methods, the class which implements or inherits that
interface can define that method.

3. Can we write body/definition of a method inside an interface?


No

4. How to prevent a class from getting inherited in c#?


By using ‘sealed’ keyword while declaring the class. For example,
public sealed class User{}

5. Method overloading and overriding


Overloading: Giving same name to two or more methods, but each having
distinct parameters and return type.
Overriding: Method of base class (declared with ‘virtual’ keyword) is overridden
by child class (declared with ‘override’ keyword), both having the same name,
similar parameters and same return type.

6. Why we use access modifiers?


Access modifiers are used to control the visibility and accessibility of classes,
methods, and variables, allowing you to define who can access and interact with
these members, promoting encapsulation and security.

7. Protected member?
Protected member is accessed either in its own class or in its derived class.

8. Folder/component names in the .NET MVC Project


Models, controllers, views, services, repository, interfaces/DTOs (Data Transfer
Objects), wwwroot (to store static files – css, images etc.), webconfig.json,
program.cs etc.

9. Can we access static files, present outside the wwwroot folder, in the Razor
view?
Yes, we can access by writing:
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new
PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(),
"MyStaticFiles")),
RequestPath = "/static"
});
10. Why to use partial view?
We use partial views to encapsulate reusable UI components or sections of a
page, improving code organization, reducing redundancy, and making
maintenance easier by allowing you to reuse the same markup in multiple
views.

11. 4 ways to return data from controller to view?


• ViewBag
• ViewData
• TempData
• Model
All explained here: https://www.csharp.com/article/asp-net-mvc-passing-data-
from-controller-to-view/

12. Action Filter in MVC?


Action filters are used to implement logic that gets executed before and after a
controller action executes.
The ASP.NET MVC framework includes several action filters:
• OutputCache – This action filter caches the output of a controller action for a
specified amount of time.
• HandleError – This action filter handles errors raised when a controller action
executes.
• Authorize – This action filter enables you to restrict access to a particular user
or role.

13. Which object is used to handle files in controller?


IFormFile

14. Middleware in .NET Core?


Middleware is software that's assembled into an app pipeline to handle
requests and responses. Each component:
• Chooses whether to pass the request to the next component in the pipeline.
• Can perform work before and after the next component in the pipeline.
15. Dependency injection in .NET Core?
Mainly useful for loose coupling.

Here, User service is directly dependent on the Email service. If we want to


change Email service, we have to change the User service too, making it tightly
coupled.
Using DI,
And configuring DI in Program.cs file.
Thus, benefits of DI are:
• Loose Coupling – Components do not depend on specific implementations.
• Better Testability – Easily replace dependencies with mock implementations.
• Improved Maintainability – Changing implementations does not require
modifying dependent classes.
16. Action verbs in API?
Get, post, put, patch and delete.

17. Three parts of JWT token?


Header, payload and signature
Header: Contains the type of token (here JWT) and contains the algorithm used
to sign the token (eg: SHA 256).
Payload: Contains the claims of the JSON object and contains all of the required
information of the user.
Signature: Generated via cryptographic algorithm and used to verify the
integrity of JSON payload.

18. Handling the versioning of APIs?


Query string
URL
HTTP header

You might also like