ASP. Net Questions Flashcards

1
Q

What is the key difference between ASP.NET Web Forms and ASP.NET MVC?

A

Web Forms: Page-centric model, server controls, ViewState.
MVC: Separation of concerns, more control over HTML, Testability.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Explain the MVC design pattern.

A

Model: Data and business logic.
View: Presentation layer.
Controller: Handles user input and controls flow.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is ViewData and ViewBag in MVC?

A

Mechanisms to pass data from controller to view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a Razor View in ASP.NET MVC?

A

View engine for generating HTML markup in MVC.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can you achieve URL routing in ASP.NET MVC?

A

Define routes in the RouteConfig file.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the key benefits of ASP.NET Core over traditional ASP.NET?

A

Cross-platform, lightweight, better performance, modularity.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Explain the concept of Middleware in ASP.NET Core.

A

Components that can handle requests and responses globally.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Dependency Injection in ASP.NET Core?

A

Pattern for injecting dependencies into classes instead of hard-coding them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How does configuration management work in ASP.NET Core?

A

Configuration stored in appsettings.json, environment variables, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the Program.cs and Startup.cs files used for in ASP.NET Core?

A

Program.cs: Main entry point.
Startup.cs: Configuration of services and middleware.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain RESTful architecture.

A

Representational State Transfer, using HTTP methods to interact with resources.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the HTTP methods used in RESTful APIs?

A

GET, POST, PUT, DELETE, PATCH, etc.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you handle versioning in a Web API?

A

URL versioning, media type versioning, query string versioning.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is content negotiation in Web API?

A

Process of selecting the appropriate response format based on client request headers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How can you handle errors in a Web API?

A

Use HTTP status codes, provide meaningful error messages, and use exception filters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Explain the concept of URL routing.

A

Mapping URLs to controller actions in MVC

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

How can you define custom routes in ASP.NET MVC?

A

Use Route attribute or configure routes in RouteConfig.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

What is attribute routing?

A

Defining routes directly on controller actions using attributes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

How does routing work in ASP.NET Core?

A

Similar to MVC, use UseEndpoints() in Startup.cs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

What is the purpose of cookies in web development?

A

Storing small pieces of data on the client side.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

How do cookies differ from sessions?

A

Cookies are stored on the client, sessions are stored on the server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Explain how sessions work in ASP.NET.

A

Server-side storage of user-specific data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is TempData in ASP.NET MVC?

A

Stores data between two consecutive requests.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
24
Q

How can you manage application state in ASP.NET Core?

A

Use services like MemoryCache or distributed caches like Redis.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is authentication? What is authorization?
Authentication: Verifying user identity. Authorization: Determining user's access rights.
26
Explain the concept of Identity in ASP.NET Core.
Framework for managing user accounts and authentication.
27
What is OAuth and how is it used for authentication?
Open standard for authorization, allowing third-party applications to access resources on behalf of users.
28
What is JWT and how does it work?
JSON Web Token: Compact, URL-safe means of representing claims between two parties.
29
How do you secure a Web API using JWT?
Issue and validate JWT tokens, verify claims.
30
What is middleware in ASP.NET Core?
Software components that form the request/response pipeline.
31
How can you create custom middleware in ASP.NET Core?
Implement the IMiddleware interface or use the UseMiddleware extension method.
32
Explain the order of execution of middleware in ASP.NET Core.
Middlewares are executed in the order they are added to the pipeline.
33
How can you conditionally branch the pipeline based on a request's properties?
Use Map and MapWhen methods.
34
What is the purpose of endpoint routing middleware in ASP.NET Core?
Matches requests to endpoints defined in the application.
35
What is ViewState in ASP.NET Web Forms?
ViewState is a client-side state management technique that allows preserving the state of server controls across postbacks
36
Explain the concept of Model Binding in ASP.NET MVC.
Model binding maps HTTP request data to action method parameters or model properties.
37
What is the role of the Global.asax file in ASP.NET applications?
Global.asax contains application-level events and configuration settings for the application lifecycle.
38
What is the purpose of TempDataDictionary in ASP.NET MVC?
TempDataDictionary is used to share data between actions during a single user's session.
39
How does Routing in ASP.NET MVC contribute to SEO-friendly URLs?
Routing allows developers to create meaningful URLs that enhance search engine optimization.
39
Explain the concept of Areas in ASP.NET MVC.
Areas allow structuring an MVC application into smaller, manageable sections.
40
What is the role of the App_Start folder in ASP.NET MVC?
App_Start contains configuration code that runs on application startup.
41
How do you handle exceptions in ASP.NET MVC?
Using try-catch blocks, custom error pages, or global exception filters.
42
What is the purpose of the Razor View Engine's @section directive?
It defines named content that can be rendered in a layout view.
43
What is an ActionResult in ASP.NET MVC?
An ActionResult is the return type of an action method, representing the result of the action's execution.
44
What is the role of the Kestrel server in ASP.NET Core?
Kestrel is a cross-platform web server used to host ASP.NET Core applications.
45
How does Dependency Injection improve the testability of ASP.NET Core applications?
Dependency Injection allows for easier isolation and mocking of dependencies during testing.
46
What is the purpose of the appsettings.json file in ASP.NET Core?
It stores application configuration settings in a JSON format
47
What are Tag Helpers in ASP.NET Core?
Tag Helpers are HTML-like elements that enable server-side code execution in Razor views.
48
Explain the concept of Razor Pages in ASP.NET Core.
Razor Pages is a page-based programming model that simplifies building web UI.
49
What is the purpose of the IWebHostEnvironment interface in ASP.NET Core?
It provides information about the environment in which the application is running.
50
How does ASP.NET Core achieve cross-platform compatibility?
Through the use of .NET Core runtime, which is designed to be platform-agnostic
51
What is the role of the app.UseAuthentication() and app.UseAuthorization() middleware?
app.UseAuthentication() sets up authentication, and app.UseAuthorization() sets up authorization in the request pipeline.
52
How can you host multiple ASP.NET Core applications on the same server?
By configuring different ports, paths, or domains for each application.
53
Explain the purpose of the IApplicationBuilder interface in ASP.NET Core.
It is used to configure the request processing pipeline.
54
What is HATEOAS (Hypermedia as the Engine of Application State) in RESTful APIs?
It refers to including hypermedia links in responses to guide client navigation.
55
How can you enable CORS (Cross-Origin Resource Sharing) in a Web API?
By configuring CORS policies to allow cross-origin requests.
56
What is versioning in the context of a Web API?
Versioning ensures backward compatibility when making changes to the API.
57
Explain the concept of content negotiation in Web API.
It involves the server and client agreeing on a suitable response format based on request headers.
58
What is the purpose of the [FromBody] attribute in Web API parameter binding?
It binds complex types from the request body to the parameter.
59
How can you implement rate limiting in a Web API?
By tracking and limiting the number of requests from a single client within a specified time frame.
60
What is the role of the IHttpActionResult interface in Web API?
It provides better control over HTTP response creation in action methods.
61
Explain the concept of content negotiation in Web API.
It involves the server and client agreeing on a suitable response format based on request headers.
62
What is the purpose of the [FromBody] attribute in Web API parameter binding?
It binds complex types from the request body to the parameter.
63
How can you implement rate limiting in a Web API?
By tracking and limiting the number of requests from a single client within a specified time frame.
64
What is the role of the IActionResult interface in Web API?
It provides better control over HTTP response creation in action methods.
65
What is the difference between conventional routing and attribute routing in ASP.NET MVC?
Conventional routing uses route templates in configuration, while attribute routing defines routes directly on actions using attributes.
66
How can you generate URLs based on routes in ASP.NET MVC?
By using the UrlHelper class in views or controllers.
67
Explain the concept of route constraints in ASP.NET MVC.
Constraints restrict which requests match a particular route based on parameter values.
68
What is route template precedence in ASP.NET Core routing?
It determines how route templates are matched when multiple templates could potentially match a given URL.
69
How can you generate URLs in ASP.NET Core using the IUrlHelper interface?
You can use methods like IUrlHelper.Action() and IUrlHelper.RouteUrl() to generate URLs.
70
What is the purpose of route parameters in ASP.NET Core routing?
Route parameters capture values from the URL and make them available to route handlers.
71
Explain the concept of route constraints in ASP.NET Core routing.
Route constraints restrict which requests match a route template based on parameter values and regular expressions.
72
What is the difference between routing in ASP.NET Core MVC and ASP.NET Core Web API?
While MVC routing maps URLs to controller actions, Web API routing maps URLs to API controllers and actions.
73
How can you handle 404 errors (Not Found) in ASP.NET Core routing?
You can configure a fallback route or use middleware to catch unhandled requests.
74
What is attribute routing in ASP.NET Core?
Attribute routing allows you to define routes directly on action methods or controllers using attributes.
75
Explain the limitations of using cookies for state management.
Cookies have size limitations, are sent with every request, and can be tampered with.
76
How can you store complex objects in session state in ASP.NET?
By serializing the object and storing it in session variables.
77
What is the difference between TempData and ViewData in ASP.NET MVC?
TempData is used to persist data between requests, while ViewData is used to transfer data between a controller and a view.
78
How does the ASP.NET Core session state differ from the session state in ASP.NET?
In ASP.NET Core, the session state is stored outside the process, making it more suitable for load-balanced environments
79
What is the purpose of the ITempDataProvider interface in ASP.NET MVC?
It defines how TempData is stored and retrieved, allowing custom implementations.
80
What are distributed caches, and how can you use them for state management in ASP.NET Core?
Distributed caches store data in a shared location accessible to multiple instances, improving scalability and performance.
81
How can you manage cookies in ASP.NET Core applications?
By using the HttpContext.Request.Cookies and HttpContext.Response.Cookies properties
82
What is the role of the IHttpContextAccessor in ASP.NET Core session management?
It provides access to the current HttpContext, which is needed to interact with session state.
83
Explain the concept of TempData and Peek in ASP.NET MVC.
TempData stores data for a single subsequent request, while Peek lets you access data without removing it from TempData.
84
How does the concept of Razor Pages in ASP.NET Core affect state management?
Razor Pages promote a more cohesive architecture by merging the view and controller concerns, simplifying state management.
85
What are bearer tokens, and how are they used in authentication?
Bearer tokens are credentials that allow a client to access a protected resource on behalf of a user.
86
Explain the role of Claims in ASP.NET Core Identity.
Claims represent pieces of information about a user and are used for authorization decisions.
87
How does OAuth 2.0 differ from OAuth 1.0a?
OAuth 2.0 is more streamlined, with token-based authorization, while OAuth 1.0a used signatures for verification.
88
What is the purpose of OAuth scopes in authentication and authorization?
Scopes define the level of access a client application has to a user's resources.
89
How can you implement social authentication (e.g., using Google or Facebook) in an ASP.NET Core application?
By configuring external authentication providers and handling the OAuth flow.
90
What is the purpose of the Authorize attribute in ASP.NET Core controllers?
It restricts access to actions based on user authentication and role membership.
91
Explain the differences between cookie-based authentication and token-based authentication.
Cookie-based authentication stores authentication information in cookies, while token-based authentication stores tokens (like JWT) in client-side storage.
92
How can you implement two-factor authentication in ASP.NET Core Identity?
By enabling 2FA options and setting up verification methods like SMS or email.
93
What is the role of Claims-based authorization in ASP.NET Core?
Claims-based authorization uses claims to determine whether a user is allowed to access a particular resource or action.
94
How can you secure WebSocket connections in ASP.NET Core applications?
By using authentication middleware and integrating WebSocket authentication.
95
What is the purpose of the UseExceptionHandler middleware in ASP.NET Core?
It catches unhandled exceptions and returns an appropriate error response.
96
How does the UseStaticFiles middleware work in ASP.NET Core?
It serves static files like HTML, CSS, and JavaScript from the wwwroot folder.
97
Explain the role of the UseRouting middleware in ASP.NET Core.
It sets up routing for incoming requests, determining which endpoint to execute.
98
What is the difference between UseAuthorization and UseAuthentication middleware in ASP.NET Core?
UseAuthentication sets up the authentication middleware, while UseAuthorization sets up the authorization middleware.
99
How can you create custom middleware to handle cross-cutting concerns in ASP.NET Core?
By implementing the IMiddleware interface and handling requests and responses.