Net Core Web API Interview Questions 1744565231
Net Core Web API Interview Questions 1744565231
- Open Source: .NET Core is open-source; .NET Framework is not fully open-
source.
3. What is Kestrel?
Kestrel is a lightweight, cross-platform web server used by ASP.NET Core. It
is the default server and sits behind IIS or Nginx in production for better
security and performance.
- Cross-platform
- Open-source
- High performance
- Built-in dependency injection
- Supports containerization
HostBuilder is used to create and configure a host for the app. It sets up
dependencies, configuration, and logging.
Model binding automatically maps HTTP request data (e.g., from query
strings, forms) to action method parameters.
18. What is Model Validation?
```csharp
[HttpGet("{id}")]
```
🔐 SECURITY & AUTHENTICATION
Authentication is the process of identifying who the user is. ASP.NET Core
supports various authentication schemes like cookie-based, JWT bearer
token, OAuth2, and OpenID Connect.
Filters are used to execute code before or after certain stages in the
request pipeline. Examples include AuthorizationFilter, ActionFilter,
ExceptionFilter, and ResultFilter.
This middleware provides responses for HTTP status codes that do not have
a response body. It can return plain text or redirect to an error page.
55. How to use Try-Catch for error handling in controller?
Wrap your logic in `try-catch` blocks and return appropriate status codes
like 400, 404, or 500 based on the exception.
Middleware that terminates the request pipeline early and doesn't call the
next middleware, typically used for security or early response handling.
Resource filters run after routing but before model binding. They can be
used for caching or authorization logic.