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
Q

What is authentication? What is authorization?

A

Authentication: Verifying user identity.
Authorization: Determining user’s access rights.

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

Explain the concept of Identity in ASP.NET Core.

A

Framework for managing user accounts and authentication.

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

What is OAuth and how is it used for authentication?

A

Open standard for authorization, allowing third-party applications to access resources on behalf of users.

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

What is JWT and how does it work?

A

JSON Web Token: Compact, URL-safe means of representing claims between two parties.

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

How do you secure a Web API using JWT?

A

Issue and validate JWT tokens, verify claims.

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

What is middleware in ASP.NET Core?

A

Software components that form the request/response pipeline.

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

How can you create custom middleware in ASP.NET Core?

A

Implement the IMiddleware interface or use the UseMiddleware extension method.

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

Explain the order of execution of middleware in ASP.NET Core.

A

Middlewares are executed in the order they are added to the pipeline.

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

How can you conditionally branch the pipeline based on a request’s properties?

A

Use Map and MapWhen methods.

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

What is the purpose of endpoint routing middleware in ASP.NET Core?

A

Matches requests to endpoints defined in the application.

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

What is ViewState in ASP.NET Web Forms?

A

ViewState is a client-side state management technique that allows preserving the state of server controls across postbacks

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

Explain the concept of Model Binding in ASP.NET MVC.

A

Model binding maps HTTP request data to action method parameters or model properties.

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

What is the role of the Global.asax file in ASP.NET applications?

A

Global.asax contains application-level events and configuration settings for the application lifecycle.

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

What is the purpose of TempDataDictionary in ASP.NET MVC?

A

TempDataDictionary is used to share data between actions during a single user’s session.

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

How does Routing in ASP.NET MVC contribute to SEO-friendly URLs?

A

Routing allows developers to create meaningful URLs that enhance search engine optimization.

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

Explain the concept of Areas in ASP.NET MVC.

A

Areas allow structuring an MVC application into smaller, manageable sections.

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

What is the role of the App_Start folder in ASP.NET MVC?

A

App_Start contains configuration code that runs on application startup.

41
Q

How do you handle exceptions in ASP.NET MVC?

A

Using try-catch blocks, custom error pages, or global exception filters.

42
Q

What is the purpose of the Razor View Engine’s @section directive?

A

It defines named content that can be rendered in a layout view.

43
Q

What is an ActionResult in ASP.NET MVC?

A

An ActionResult is the return type of an action method, representing the result of the action’s execution.

44
Q

What is the role of the Kestrel server in ASP.NET Core?

A

Kestrel is a cross-platform web server used to host ASP.NET Core applications.

45
Q

How does Dependency Injection improve the testability of ASP.NET Core applications?

A

Dependency Injection allows for easier isolation and mocking of dependencies during testing.

46
Q

What is the purpose of the appsettings.json file in ASP.NET Core?

A

It stores application configuration settings in a JSON format

47
Q

What are Tag Helpers in ASP.NET Core?

A

Tag Helpers are HTML-like elements that enable server-side code execution in Razor views.

48
Q

Explain the concept of Razor Pages in ASP.NET Core.

A

Razor Pages is a page-based programming model that simplifies building web UI.

49
Q

What is the purpose of the IWebHostEnvironment interface in ASP.NET Core?

A

It provides information about the environment in which the application is running.

50
Q

How does ASP.NET Core achieve cross-platform compatibility?

A

Through the use of .NET Core runtime, which is designed to be platform-agnostic

51
Q

What is the role of the app.UseAuthentication() and app.UseAuthorization() middleware?

A

app.UseAuthentication() sets up authentication, and app.UseAuthorization() sets up authorization in the request pipeline.

52
Q

How can you host multiple ASP.NET Core applications on the same server?

A

By configuring different ports, paths, or domains for each application.

53
Q

Explain the purpose of the IApplicationBuilder interface in ASP.NET Core.

A

It is used to configure the request processing pipeline.

54
Q

What is HATEOAS (Hypermedia as the Engine of Application State) in RESTful APIs?

A

It refers to including hypermedia links in responses to guide client navigation.

55
Q

How can you enable CORS (Cross-Origin Resource Sharing) in a Web API?

A

By configuring CORS policies to allow cross-origin requests.

56
Q

What is versioning in the context of a Web API?

A

Versioning ensures backward compatibility when making changes to the API.

57
Q

Explain the concept of content negotiation in Web API.

A

It involves the server and client agreeing on a suitable response format based on request headers.

58
Q

What is the purpose of the [FromBody] attribute in Web API parameter binding?

A

It binds complex types from the request body to the parameter.

59
Q

How can you implement rate limiting in a Web API?

A

By tracking and limiting the number of requests from a single client within a specified time frame.

60
Q

What is the role of the IHttpActionResult interface in Web API?

A

It provides better control over HTTP response creation in action methods.

61
Q

Explain the concept of content negotiation in Web API.

A

It involves the server and client agreeing on a suitable response format based on request headers.

62
Q

What is the purpose of the [FromBody] attribute in Web API parameter binding?

A

It binds complex types from the request body to the parameter.

63
Q

How can you implement rate limiting in a Web API?

A

By tracking and limiting the number of requests from a single client within a specified time frame.

64
Q

What is the role of the IActionResult interface in Web API?

A

It provides better control over HTTP response creation in action methods.

65
Q

What is the difference between conventional routing and attribute routing in ASP.NET MVC?

A

Conventional routing uses route templates in configuration, while attribute routing defines routes directly on actions using attributes.

66
Q

How can you generate URLs based on routes in ASP.NET MVC?

A

By using the UrlHelper class in views or controllers.

67
Q

Explain the concept of route constraints in ASP.NET MVC.

A

Constraints restrict which requests match a particular route based on parameter values.

68
Q

What is route template precedence in ASP.NET Core routing?

A

It determines how route templates are matched when multiple templates could potentially match a given URL.

69
Q

How can you generate URLs in ASP.NET Core using the IUrlHelper interface?

A

You can use methods like IUrlHelper.Action() and IUrlHelper.RouteUrl() to generate URLs.

70
Q

What is the purpose of route parameters in ASP.NET Core routing?

A

Route parameters capture values from the URL and make them available to route handlers.

71
Q

Explain the concept of route constraints in ASP.NET Core routing.

A

Route constraints restrict which requests match a route template based on parameter values and regular expressions.

72
Q

What is the difference between routing in ASP.NET Core MVC and ASP.NET Core Web API?

A

While MVC routing maps URLs to controller actions, Web API routing maps URLs to API controllers and actions.

73
Q

How can you handle 404 errors (Not Found) in ASP.NET Core routing?

A

You can configure a fallback route or use middleware to catch unhandled requests.

74
Q

What is attribute routing in ASP.NET Core?

A

Attribute routing allows you to define routes directly on action methods or controllers using attributes.

75
Q

Explain the limitations of using cookies for state management.

A

Cookies have size limitations, are sent with every request, and can be tampered with.

76
Q

How can you store complex objects in session state in ASP.NET?

A

By serializing the object and storing it in session variables.

77
Q

What is the difference between TempData and ViewData in ASP.NET MVC?

A

TempData is used to persist data between requests, while ViewData is used to transfer data between a controller and a view.

78
Q

How does the ASP.NET Core session state differ from the session state in ASP.NET?

A

In ASP.NET Core, the session state is stored outside the process, making it more suitable for load-balanced environments

79
Q

What is the purpose of the ITempDataProvider interface in ASP.NET MVC?

A

It defines how TempData is stored and retrieved, allowing custom implementations.

80
Q

What are distributed caches, and how can you use them for state management in ASP.NET Core?

A

Distributed caches store data in a shared location accessible to multiple instances, improving scalability and performance.

81
Q

How can you manage cookies in ASP.NET Core applications?

A

By using the HttpContext.Request.Cookies and HttpContext.Response.Cookies properties

82
Q

What is the role of the IHttpContextAccessor in ASP.NET Core session management?

A

It provides access to the current HttpContext, which is needed to interact with session state.

83
Q

Explain the concept of TempData and Peek in ASP.NET MVC.

A

TempData stores data for a single subsequent request, while Peek lets you access data without removing it from TempData.

84
Q

How does the concept of Razor Pages in ASP.NET Core affect state management?

A

Razor Pages promote a more cohesive architecture by merging the view and controller concerns, simplifying state management.

85
Q

What are bearer tokens, and how are they used in authentication?

A

Bearer tokens are credentials that allow a client to access a protected resource on behalf of a user.

86
Q

Explain the role of Claims in ASP.NET Core Identity.

A

Claims represent pieces of information about a user and are used for authorization decisions.

87
Q

How does OAuth 2.0 differ from OAuth 1.0a?

A

OAuth 2.0 is more streamlined, with token-based authorization, while OAuth 1.0a used signatures for verification.

88
Q

What is the purpose of OAuth scopes in authentication and authorization?

A

Scopes define the level of access a client application has to a user’s resources.

89
Q

How can you implement social authentication (e.g., using Google or Facebook) in an ASP.NET Core application?

A

By configuring external authentication providers and handling the OAuth flow.

90
Q

What is the purpose of the Authorize attribute in ASP.NET Core controllers?

A

It restricts access to actions based on user authentication and role membership.

91
Q

Explain the differences between cookie-based authentication and token-based authentication.

A

Cookie-based authentication stores authentication information in cookies, while token-based authentication stores tokens (like JWT) in client-side storage.

92
Q

How can you implement two-factor authentication in ASP.NET Core Identity?

A

By enabling 2FA options and setting up verification methods like SMS or email.

93
Q

What is the role of Claims-based authorization in ASP.NET Core?

A

Claims-based authorization uses claims to determine whether a user is allowed to access a particular resource or action.

94
Q

How can you secure WebSocket connections in ASP.NET Core applications?

A

By using authentication middleware and integrating WebSocket authentication.

95
Q

What is the purpose of the UseExceptionHandler middleware in ASP.NET Core?

A

It catches unhandled exceptions and returns an appropriate error response.

96
Q

How does the UseStaticFiles middleware work in ASP.NET Core?

A

It serves static files like HTML, CSS, and JavaScript from the wwwroot folder.

97
Q

Explain the role of the UseRouting middleware in ASP.NET Core.

A

It sets up routing for incoming requests, determining which endpoint to execute.

98
Q

What is the difference between UseAuthorization and UseAuthentication middleware in ASP.NET Core?

A

UseAuthentication sets up the authentication middleware, while UseAuthorization sets up the authorization middleware.

99
Q

How can you create custom middleware to handle cross-cutting concerns in ASP.NET Core?

A

By implementing the IMiddleware interface and handling requests and responses.