Untitled Deck Flashcards

1
Q

What’s the main difference between ASP.NET and .NET (Core/.NET 9)?

A

.NET 9 is cross-platform, modular, faster, and does not use System.Web. It uses a middleware pipeline and has built-in dependency injection.

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

Which core file replaces Global.asax in .NET 9?

A

Program.cs (and optionally Startup.cs in older versions) replaces Global.asax for application startup and configuration.

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

What are the three main DI lifetimes in .NET 9?

A

Transient: New instance every time
Scoped: One instance per HTTP request
Singleton: One instance for the app’s lifetime

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

When should you use Transient?

A

When the service is lightweight and stateless — ideal for short-lived operations or logic.

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

When should you use Scoped?

A

When the service needs to maintain state throughout a single request, like a DbContext.

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

When should you use Singleton?

A

When the service is thread-safe and should be shared across the app’s lifetime, like a cache or configuration reader.

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

What’s the danger of using Singleton for DbContext?

A

DbContext isn’t thread-safe — using it as a singleton causes threading issues and shared-state bugs.

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

How do you register a service in .NET 9 DI?

A

builder.Services.AddScoped<IMyService, MyService>();

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

How does constructor injection work in .NET 9?

A

Dependencies are declared in a class constructor and automatically injected by the framework.

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

What should you do if an ASP.NET app doesn’t use DI?

A

Refactor direct new calls and static helpers into injectable services using interfaces and register them in DI.

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

How should static helper methods be handled during migration?

A

Move logic into classes implementing interfaces and register those in the DI container.

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

What replaces HttpModules and Global.asax event hooks in .NET 9?

A

Middleware in the Program.cs pipeline (e.g., app.UseRouting(), app.UseAuthentication()).

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

How is configuration handled differently in .NET 9?

A

.NET 9 uses appsettings.json and the IConfiguration API instead of web.config.

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

What CLI tool helps migrate old project files to SDK style?

A

try-convert

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

What routing system replaces RouteConfig.cs in .NET 9?

A

Endpoint Routing in Program.cs using app.MapControllers() or app.MapGet().

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

What’s a good first migration step if the app uses Web Forms?

A

Plan a rewrite using Razor Pages or MVC, since Web Forms aren’t supported in .NET 9.

17
Q

What should you replace HttpContext.Current with?

A

Use constructor-injected IHttpContextAccessor.

18
Q

Why is ASP.NET Core considered more testable?

A

Constructor injection and built-in DI make it easier to mock dependencies for unit testing.

19
Q

What should you check when migrating third-party libraries?

A

Ensure they have .NET Standard or .NET 9-compatible packages on NuGet. Replace unsupported ones.

20
Q

What’s a modern replacement for ASP.NET’s BundleConfig?

A

Use frontend tools like Webpack, or BundlerMinifier.Core for .NET projects.