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.