ASP. Net Questions Flashcards
What is the key difference between ASP.NET Web Forms and ASP.NET MVC?
Web Forms: Page-centric model, server controls, ViewState.
MVC: Separation of concerns, more control over HTML, Testability.
Explain the MVC design pattern.
Model: Data and business logic.
View: Presentation layer.
Controller: Handles user input and controls flow.
What is ViewData and ViewBag in MVC?
Mechanisms to pass data from controller to view.
What is a Razor View in ASP.NET MVC?
View engine for generating HTML markup in MVC.
How can you achieve URL routing in ASP.NET MVC?
Define routes in the RouteConfig file.
What are the key benefits of ASP.NET Core over traditional ASP.NET?
Cross-platform, lightweight, better performance, modularity.
Explain the concept of Middleware in ASP.NET Core.
Components that can handle requests and responses globally.
What is Dependency Injection in ASP.NET Core?
Pattern for injecting dependencies into classes instead of hard-coding them.
How does configuration management work in ASP.NET Core?
Configuration stored in appsettings.json, environment variables, etc.
What is the Program.cs and Startup.cs files used for in ASP.NET Core?
Program.cs: Main entry point.
Startup.cs: Configuration of services and middleware.
Explain RESTful architecture.
Representational State Transfer, using HTTP methods to interact with resources.
What are the HTTP methods used in RESTful APIs?
GET, POST, PUT, DELETE, PATCH, etc.
How do you handle versioning in a Web API?
URL versioning, media type versioning, query string versioning.
What is content negotiation in Web API?
Process of selecting the appropriate response format based on client request headers.
How can you handle errors in a Web API?
Use HTTP status codes, provide meaningful error messages, and use exception filters.
Explain the concept of URL routing.
Mapping URLs to controller actions in MVC
How can you define custom routes in ASP.NET MVC?
Use Route attribute or configure routes in RouteConfig.
What is attribute routing?
Defining routes directly on controller actions using attributes.
How does routing work in ASP.NET Core?
Similar to MVC, use UseEndpoints() in Startup.cs.
What is the purpose of cookies in web development?
Storing small pieces of data on the client side.
How do cookies differ from sessions?
Cookies are stored on the client, sessions are stored on the server.
Explain how sessions work in ASP.NET.
Server-side storage of user-specific data.
What is TempData in ASP.NET MVC?
Stores data between two consecutive requests.
How can you manage application state in ASP.NET Core?
Use services like MemoryCache or distributed caches like Redis.
What is authentication? What is authorization?
Authentication: Verifying user identity.
Authorization: Determining user’s access rights.
Explain the concept of Identity in ASP.NET Core.
Framework for managing user accounts and authentication.
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.
What is JWT and how does it work?
JSON Web Token: Compact, URL-safe means of representing claims between two parties.
How do you secure a Web API using JWT?
Issue and validate JWT tokens, verify claims.
What is middleware in ASP.NET Core?
Software components that form the request/response pipeline.
How can you create custom middleware in ASP.NET Core?
Implement the IMiddleware interface or use the UseMiddleware extension method.
Explain the order of execution of middleware in ASP.NET Core.
Middlewares are executed in the order they are added to the pipeline.
How can you conditionally branch the pipeline based on a request’s properties?
Use Map and MapWhen methods.
What is the purpose of endpoint routing middleware in ASP.NET Core?
Matches requests to endpoints defined in the application.
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
Explain the concept of Model Binding in ASP.NET MVC.
Model binding maps HTTP request data to action method parameters or model properties.
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.
What is the purpose of TempDataDictionary in ASP.NET MVC?
TempDataDictionary is used to share data between actions during a single user’s session.
How does Routing in ASP.NET MVC contribute to SEO-friendly URLs?
Routing allows developers to create meaningful URLs that enhance search engine optimization.
Explain the concept of Areas in ASP.NET MVC.
Areas allow structuring an MVC application into smaller, manageable sections.