ASP.NET with essential interview questions and answers. Perfect for beginners and pros, this guide boosts your skills and interview readiness. At Softloom IT Training
1. What does ASP.NET stand for?
A) Active Server Pages .NET
B) Advanced Server Pages .NET
C) Application Server Pages .NET
D) Automated Server Pages .NET
Answer: A) Active Server Pages .NET
2. ASP.NET is developed by which company?
A) Google
B) Microsoft
C) IBM
D) Oracle
Answer: B) Microsoft
3. Which programming language is primarily used in ASP.NET?
A) C++
B) Java
C) C#
D) Python
Answer: C) C#
4. What is the` primary function of the ASP.NET framework?
A) Develop mobile applications
B) Develop dynamic web applications
C) Develop desktop applications
D) Develop database management systems
Answer: B) Develop dynamic web applications
5. Which model does ASP.NET use for web development?
A) MVC (Model-View-Controller)
B) MVVM (Model-View-ViewModel)
C) MVP (Model-View-Presenter)
D) All of the above
Answer: A) MVC (Model-View-Controller)
6. Which of the following is the default session state in ASP.NET?
A) In-Process
B) State Server
C) SQL Server
D) Custom
Answer: A) In-Process
7. What is the extension of an ASP.NET web page file?
A) .html
B) .php
C) .aspx
D) .jsp
Answer: C) .aspx
8. Which method is used to force a page to be posted back to the server in ASP.NET?
A) PostBack()
B) IsPostBack()
C) Response.Redirect()
D) Server.Transfer()
Answer: B) IsPostBack()
9. What is ViewState in ASP.NET?
A) A method for storing session state
B) A method for preserving data between postbacks
C) A security feature in ASP.NET
D) A database optimization technique
Answer: B) A method for preserving data between postbacks
10. What is the purpose of the Global.asax file?
A) Storing user credentials
B) Handling global application events
C) Managing database connections
D) Storing configuration settings
Answer: B) Handling global application events
11. Which of the following is NOT an ASP.NET server control?
A) GridView
B) DropDownList
C) CheckBox
D) AlertBox
Answer: D) AlertBox
12. What is the role of Web.config in an ASP.NET application?
A) Storing database records
B) Configuring application settings
C) Defining CSS styles
D) Managing HTML structure
Answer: B) Configuring application settings
13. Which of the following is used for routing in ASP.NET MVC?
A) RouteConfig.cs
B) Global.asax
C) Web.config
D) Index.cshtml
Answer: A) RouteConfig.cs
14. What does IIS stand for in the context of ASP.NET?
A) Internet Information Services
B) Internal Information Server
C) Integrated Internet System
D) Interactive Internet Services
Answer: A) Internet Information Services
15. Which of the following authentication modes is available in ASP.NET?
A) Windows
B) Forms
C) Passport
D) All of the above
Answer: D) All of the above
16. What is the function of the Session object in ASP.NET?
A) Stores user session data
B) Stores database records
C) Stores CSS styles
D) Stores web service data
Answer: A) Stores user session data
17. Which of the following represents a server-side scripting language in ASP.NET?
A) JavaScript
B) VB.NET
C) CSS
D) HTML
Answer: B) VB.NET
18. What is Razor in ASP.NET?
A) A JavaScript framework
B) A database tool
C) A view engine for ASP.NET
D) A web security feature
Answer: C) A view engine for ASP.NET
19. Which of the following is a lifecycle event of an ASP.NET page?
A) Page_Init
B) Page_Load
C) Page_PreRender
D) All of the above
Answer: D) All of the above
20. What does AJAX stand for in ASP.NET?
A) Asynchronous JavaScript and XML
B) Advanced Java Application eXchange
C) Automated JavaScript and XHTML
D) Asynchronous JSON and XML
Answer: A) Asynchronous JavaScript and XML
21. What does the Server.Transfer() method do?
A) Redirects to another page on the same server
B) Redirects to an external website
C) Downloads a file from the server
D) Stops the web application
Answer: A) Redirects to another page on the same server
22. What is the difference between Response.Redirect() and Server.Transfer()?
A) Response.Redirect() changes the URL in the browser, Server.Transfer() does not
B) Server.Transfer() changes the URL in the browser, Response.Redirect() does not
C) Both methods work the same way
D) Response.Redirect() only works in MVC
Answer: A) Response.Redirect() changes the URL in the browser, Server.Transfer() does not
23. Which of the following can be used for state management in ASP.NET?
A) ViewState
B) Session
C) Cookies
D) All of the above
Answer: D) All of the above
24. How do you comment a single line in C#?
A) // This is a comment
B) /* This is a comment */
C) <!– This is a comment –>
D) # This is a comment
Answer: A) // This is a comment
25. What is a Master Page in ASP.NET?
A) A template for multiple web pages
B) A class for database connectivity
C) A type of authentication method
D) A tool for error handling
Answer: A) A template for multiple web pages
26. What is the default language used in ASP.NET code-behind files?
A) Python
B) C#
C) Java
D) PHP
Answer: B) C#
27. What does the Runat=”server” attribute do in ASP.NET?
- A) Makes an HTML element a server-side control
B) Runs JavaScript on the server
C) Runs the application on the client-side
D) Compiles the HTML file
Answer: A) Makes an HTML element a server-side control
28. What is the use of HttpContext in ASP.NET?
A) It stores information about the current HTTP request
B) It provides debugging information
C) It is used for database connectivity
D) It controls JavaScript execution
Answer: A) It stores information about the current HTTP request
29. Which method is used to clear a session in ASP.NET?
A) Session.Clear()
B) Session.RemoveAll()
C) Session.Abandon()
D) All of the above
Answer: D) All of the above
30. What is ASP.NET Core?
A) A lightweight, cross-platform version of ASP.NET
B) A database engine
C) A JavaScript framework
D) A browser extension
Answer: A) A lightweight, cross-platform version of ASP.NET
31. What is the default access modifier for class members in C#?
A. public
B. private
C. internal
D. protected
Answer: B. private
32. What does EF Core stand for?
A. Entity Forms Core
B. Entity Framework Core
C. Enterprise Framework Core
D. Entity Factory Core
Answer: B. Entity Framework Core
33. Which class in EF Core represents a session with the database?
A. DbLink
B. SqlContext
C. DbContext
D. DataSession
Answer: C. DbContext
34. What is the default return type for a Web API controller method?
A. JsonResult
B. IActionResult
C. string
D. Object
Answer: B. IActionResult
35. In ASP.NET Core, ConfigureServices() method is used for:
A. Configuring middleware
B. Configuring services and dependency injection
C. Creating the database
D. Configuring logging only
Answer: B. Configuring services and dependency injection
36. Which of the following registers a service with a scoped lifetime?
A. services.AddSingleton<IService, MyService>()
B. services.AddTransient<IService, MyService>()
C. services.AddScoped<IService, MyService>()
D. services.RegisterScoped<IService, MyService>()
✅ Answer: C
37. What is the difference between AddSingleton and AddTransient?
A. Singleton creates per request, Transient creates once
B. Singleton creates once, Transient creates a new instance per request
C. Both are the same
D. Singleton uses a static class
✅ Answer: B
38. Which of these is the correct order for configuring middleware?
A. UseRouting -> UseAuthorization -> UseEndpoints
B. UseEndpoints -> UseRouting -> UseAuthorization
C. UseAuthorization -> UseEndpoints -> UseRouting
D. UseEndpoints -> UseAuthorization -> UseRouting
✅ Answer: A
39. Which interface is used to access the HTTP context in a service class?
A. IHttpClientFactory
B. IHttpContextAccessor
C. IWebHostEnvironment
D. IRequestHandler
✅ Answer: B
40. What are services?AddDbContext<ApplicationDbContext>() do?
A. Adds authentication
B. Adds an HTTP client
C. Registers EF Core DB context in DI
D. Adds MVC features
✅ Answer: C
41. What is the default directory for static files?
A. /assets
B. /www
C. /wwwroot
D. /public
✅ Answer: C
42. What is the purpose of app.UseAuthentication()?
A. Checks for static files
B. Enforces user access rules
C. Registers authentication middleware
D. Adds authorization rules
✅ Answer: C
43. How do you enable static files (e.g., images, CSS, JS) in ASP.NET Core?
A. app.UseStaticFiles()
B. app.EnableStatic()
C. services.AddStaticFiles()
D. app.Static()
✅ Answer: A
44. Which method is used to seed initial data in EF Core?
A. SeedDatabase()
B. OnSeed()
C. HasData()
D. InsertInitialData()
✅ Answer: C
45. Which tag helper is used to generate a form in Razor view?
A. form-helper
B. form-tag
C. <form asp-controller=”Home” asp-action=”Save”>
D. @Form()
✅ Answer: C
46. Which ORM is commonly used with ASP.NET Core?
A. Hibernate
B. Dapper
C. Entity Framework Core
D. Sequelize
Answer: C
47. What does AddControllers() do in ASP.NET Core?
A. Adds MVC and Razor pages
B. Registers services required for API controllers
C. Adds Entity Framework support
D. Configures Kestrel server
Answer: B
48. Which file in ASP.NET Core replaces Web.config from classic ASP.NET?
A. Startup.cs
B. Program.cs
C. appsettings.json
D. Global.asax
Answer: C
49. What is the default lifetime of services registered with AddTransient?
A. Same instance for the entire application
B. Same instance per HTTP request
C. New instance every time it’s requested
D. Cached permanently
Answer: C
50. Which of the following methods is used to configure middleware pipeline?
A. ConfigureServices()
B. Configure()
C. Main()
D. UseServices()
Answer: B
51. In ASP.NET Core MVC, ViewData is:
A. Strongly typed data transfer method
B. Dictionary of key-value pairs
C. Session state storage
D. Temp storage only
Answer: B
52. Which of these is NOT true about Razor Pages?
A. It follows a page-based programming model
B. Each page has a .cshtml and .cshtml.cs file
C. It requires controllers to work
D. It is built on top of MVC
Answer: C
53. What is the default logging provider in ASP.NET Core?
A. Serilog
B. NLog
C. Console
D. ELMAH
Answer: C
54. In ASP.NET Core Web API, which attribute is used to specify a route for a controller?
A. [HttpRoute]
B. [Route]
C. [Path]
D. [Map]
Answer: B
55. Which HTTP method is idempotent according to REST principles?
A. POST
B. PUT
C. PATCH
D. DELETE
Answer: B