Basic ASP.NET Interview Questions (Freshers)
These foundational questions cover core concepts of ASP.NET, ideal for freshers entering the web development field.
1. What is ASP.NET?
ASP.NET is a server-side web framework by Microsoft for building dynamic web applications and services using .NET languages like C#.[1]
2. How does ASP.NET work?
ASP.NET receives client requests via a web server like IIS, processes server-side code to generate HTML or other responses, and sends them back to the client.[1]
3. What is the Common Language Runtime (CLR) in ASP.NET?
CLR manages code execution, memory allocation, garbage collection, and thread management for ASP.NET applications.[1]
4. What is managed code versus unmanaged code?
Managed code runs under CLR with automatic memory management, while unmanaged code does not target CLR and requires manual handling.[1][6]
5. What are the main types of validation controls in ASP.NET?
Key validators include RequiredFieldValidator for mandatory fields, CompareValidator for comparisons, RangeValidator for ranges, RegularExpressionValidator for patterns, and CustomValidator for custom logic.[1]
6. What is PostBack in ASP.NET?
PostBack occurs when a page sends data back to the same page on the server, checked via the IsPostBack property.[4]
7. What is ViewState in ASP.NET?
ViewState stores page state data between postbacks in a hidden field, maintaining control values across requests.
8. Explain caching in ASP.NET.
Caching stores frequently used data in memory to improve performance, with types like page caching, fragment caching, and data caching.[6]
9. What is an Application object in ASP.NET?
Application object shares data across all users of the application, useful for global settings.[2]
10. What are the differences between Debug and Release builds in ASP.NET?
Debug builds include symbols for breakpoints but are slower; Release builds are optimized for speed without debug data.[2]
Intermediate ASP.NET Interview Questions (1-3 Years Experience)
These questions dive into practical implementation and ASP.NET features for developers with some hands-on experience.
11. What are User Controls versus Custom Controls in ASP.NET?
User Controls are reusable page sections within one application; Custom Controls are compiled assemblies reusable across multiple applications.[2]
12. List some page events in the ASP.NET page life cycle.
Key events include Page_Init, Page_Load, Page_PreRender, and Page_Unload for handling page processing stages.[4]
13. What is Session state in ASP.NET?
Session state stores user-specific data across requests, typically in server memory or state servers.
14. Explain the trace methods in ASP.NET.
Methods include Assert() for condition checks, Fail() for errors, Close() for cleanup, and GetType() for object type.[1]
15. What is the difference between ASP.NET Web Forms and MVC?
Web Forms uses event-driven programming with server controls; MVC separates Model, View, and Controller for better structure.[1][4]
16. How does state management work in ASP.NET?
ASP.NET manages state via ViewState, Session, Application, Cookies, and QueryStrings for different scopes.[1]
17. What are Action Results in ASP.NET MVC?
Types include ViewResult for views, RedirectResult for redirects, JsonResult for JSON, FileResult for files, and ContentResult for strings.[3]
18. Explain functional versus non-functional requirements in ASP.NET projects.
Functional requirements define core features; non-functional cover performance, security, and usability qualities.[2]
19. What is Reflection in ASP.NET?
Reflection allows runtime inspection of metadata, dynamic method invocation, and object creation using System.Reflection.[2][5]
20. How do you handle exceptions in ASP.NET using try-catch-finally?
Try contains code to test, catch handles exceptions, and finally executes cleanup code regardless of exceptions.[4]
Advanced ASP.NET Interview Questions (3-6 Years Experience)
Scenario-based and advanced questions for experienced developers, focusing on optimization and real-world scenarios at companies like Zoho or Atlassian.
21. What is Middleware in ASP.NET Core?
Middleware processes HTTP requests and responses in a pipeline, handling logging, authentication, and routing.[3]
22. Explain Dependency Injection in ASP.NET Core.
DI provides instances to classes via constructors, improving testability; ASP.NET Core has built-in services like AddScoped, AddTransient.[5]
23. Scenario: At Paytm, how would you implement custom validation for payment forms?
Use CustomValidator with server-side logic to validate card numbers against patterns and API checks before processing.[1]
24. What is the diamond problem in ASP.NET inheritance?
It arises in multiple inheritance scenarios where ambiguous method overrides occur; .NET supports single class inheritance to avoid it.[2]
25. How do you optimize ASP.NET applications for high traffic like at Flipkart?
Implement output caching, use Session State Server, enable compression, and minimize ViewState usage.[6]
26. Scenario: Design routing for a Salesforce-like CRM in ASP.NET MVC.
Use attribute routing on controllers with constraints:
[Route("api/crm/{id:int}")] public IActionResult GetCustomer(int id) { ... }
[3]
27. Explain async/await in ASP.NET for scalable APIs.
Async methods free threads during I/O operations:
public async Task<string> GetDataAsync() { var data = await httpClient.GetStringAsync(url); return data; }
[5]
28. How do you prevent CSRF attacks in ASP.NET?
Use AntiForgeryToken() in forms and ValidateAntiForgeryToken attribute on actions to verify request authenticity.[4]
29. Scenario: At Adobe, handle multiple models in one view for a dashboard.
Create a parent ViewModel combining models:
public class DashboardViewModel { public Model1 Data1 { get; set; } public Model2 Data2 { get; set; } }
[4]
30. What are the advantages of interfaces over abstract classes in ASP.NET?
Interfaces support multiple inheritance, define contracts without implementation; abstract classes provide shared code but single inheritance.[5]