ASP.NET MCQs
Q.1. How can you enable tracing for an ASP.NET Web Forms page?
A. Add Trace=”true” in the @Page directive
B. Set Trace=”enabled” in the web.config
C. Enable tracing in IIS
D. Add a trace directive in the Global.asax
Q.2 Which method is used to bind data to a GridView control in ASP.NET Web Forms?
A. DataBind()
B. BindData()
C. SetData()
D. BindGrid
Q.3 How can you trigger a Button click event in ASP.NET Web Forms?
A. Using the Click attribute
B. Using the OnClick attribute
C. Using the Command attribute
D. Using the Submit attribute
Q.4 What is the correct syntax to retrieve the value of a TextBox control named txtName in the code-behind?
A. txtName.Text
B. txtName.Value
C. txtName.Content
D. txtName.Input
Q.5 How do you programmatically set the text of a Label control named lblMessage?
A. lblMessage.Text = “Hello”;
B. lblMessage.Value = “Hello”;
C. lblMessage.Content = “Hello”;
D. lblMessage.Caption = “Hello”;
Q.6 Which control in ASP.NET Web Forms allows for inputting multi-line text?
A. TextBox
B. Label
C. TextArea
D. MultiTextBox
Q.7 What does the IsPostBack property indicate?
A. Whether the page is being loaded for the first time
B. Whether the page has been redirected
C. Whether the page is posted back to itself
D. Whether the page contains valid data
Q.8 Which control is used to display static text in an ASP.NET Web Form?
A. TextBox
B. Label
C. Button
D. HyperLink
Q.9 What is the purpose of ViewState in ASP.NET Web Forms?
A. To store client-side data
B. To manage user sessions
C. To maintain the state of a web page between postbacks
D. To handle database connections
Q.10 Which event occurs first in the Web Forms page life cycle?
A. Page_Load
B. Page_Init
C. Page_PreRender
D. Page_Unload
Q.11 What is the primary use of ASP.NET Web Forms?
A. Creating REST APIs
B. Building dynamic web pages
C. Managing databases
D. Handling server configuration
Q.12 How can you handle errors in an ASP.NET application globally?
A. By using try-catch blocks in every method
B. By handling the Application_Error event in Global.asax
C. By setting custom error pages in the web.config
D. By writing error-handling code in each page
Q.13 What tool can be used for debugging ASP.NET applications in Visual Studio?
A. ASP.NET Debugger
B. Web Debugger
C. Server Debugger
D. Integrated Debugger
Q.14 What is the correct syntax for defining a connection string in web.config?
A. <connectionStrings><add name=”MyDB” connectionString=”…” providerName=”…” /></connectionStrings>
B. <connectionStrings><connection name=”MyDB” string=”…” /></connectionStrings>
C. <connections><add name=”MyDB” string=”…” /></connections>
D. <connections><connection name=”MyDB” string=”…” /></connections>
Q.15 How can you enable tracing in an ASP.NET application?
A. By setting Trace=”true” in the @Page directive
B. By adding trace=”true” in the web.config file
C. By setting Trace=”enabled” in the global.asax file
D. By including a trace directive in the master page
Q.16 Which method is used to redirect a user to another page in ASP.NET?
A. Response.Redirect()
B. Page.Transfer()
C. Server.Redirect()
D. Page.Redirect()
Q.17 What is the function of a View in the MVC framework?
A. To handle user inputs
B. To update the model
C. To render the UI
D. To manage data access
Q.18 Which architectural pattern does ASP.NET MVC follow?
A. Model-View-Presenter
B. Model-View-Controller
C. View-Controller-Model
D. Model-Controller-View
Q.19 What is the purpose of the web.config file in ASP.NET?
A. To configure server settings
B. To configure application settings
C. To define user roles
D. All of the above
Q.20 What does the Page Lifecycle in ASP.NET refer to?
A. The stages an ASP.NET page goes through from initialization to disposal
B. The process of compiling ASP.NET pages
C. The steps involved in deploying an ASP.NET application
D. The sequence of database operations
Q.21 Which of the following is an ASP.NET server control?
A. <div>
B. asp:Button
C. <header>
D. <input>
Q.22 What is the role of the Global.asax file in ASP.NET applications?
A. To store application-level events and settings
B. To define CSS styles
C. To handle database connections
D. To manage user authentication
Q.23 Which component in ASP.NET handles the HTTP requests and responses?
A. Page Controller
B. HttpHandler
C. View Engine
D. Route Handler
Q.24 What ASP.NET directive is used to include a user control in an ASPX page?
A. <%@ Include File=”UserControl.ascx” %>
B. <%@ Register Src=”UserControl.ascx” TagPrefix=”uc” TagName=”MyControl” %>
C. <%@ Import Namespace=”UserControl.ascx” %>
D. <%@ Assembly Name=”UserControl.ascx” %>
Q.25 What is ASP.NET Web Forms used for?
A. Building REST APIs
B. Creating dynamic web pages
C. Server management
D. Database administration
Q.26 What does the ‘ASP’ in ASP.NET stand for?
A. Active Server Pages
B. Application Service Pages
C. Active Service Pages
D. Application Server Pages
Q.27 Which of the following is NOT a feature of ASP.NET?
A. Web Forms
B. MVC
C. Routing
D. React.js
Q.28 ASP.NET applications can be hosted on which of the following?
A. Windows Server
B. Linux
C. MacOS
D. All of the above
Q.29 Which language is primarily used for ASP.NET web application development?
A. Java
B. C#
C. Python
D. Ruby
Q.30 What is the primary function of ASP.NET in web development?
A. To facilitate the creation of static HTML websites
B. To develop dynamic web pages, web applications, and web services
C. To provide database management tools
D. To enhance client-side scripting capabilities
Q.31 How do you store a value in Session State in ASP.NET?
A. Session.Add(“key”, value);
B. Session[“key”] = value;
C. Session.Set(“key”, value);
D. Session.Put(“key”, value);
Q.32 What is the difference between Session State and Application State in ASP.NET?
A. Session State is for a single user, Application State is shared among all users
B. Application State is for a single user, Session State is shared among all users
C. Both are the same
D. None of the above
Q.33 Which of the following is a client-side state management technique in ASP.NET?
A. Session State
B. Application State
C. Cookies
D. Database storage
Q.34 What is the purpose of ViewState in ASP.NET?
A. To store data on the server
B. To maintain the state of web controls between postbacks
C. To manage user sessions
D. To handle database connections
Q.35 Which of the following is a server-side state management technique in ASP.NET?
A. ViewState
B. Cookies
C. Session State
D. Query Strings
Q.36 What is state management in ASP.NET?
A. Handling user authentication
B. Managing database connections
C. Preserving data over multiple requests
D. Optimizing server performance
Q.37 What is a common issue that can cause routing errors in ASP.NET MVC?
A. Incorrect action names
B. Mismatched parameter types
C. Missing route templates
D. All of the above
Q.38 How can you test if a route is correctly configured in ASP.NET MVC?
A. By checking the URL in the browser
B. By using the RouteDebugger tool
C. By inspecting the RouteConfig.cs file
D. By using the Debug.WriteLine() method
Q.39 How do you define a route constraint in attribute routing?
A. [Route(“route/{id:int}”)]
B. [Route(“route/{id:constraint}”)]
C. [Route(“route/{id:regex}”)]
D. [Route(“route/{id:type}”)]
Q.40 What is the correct way to define a custom route using attribute routing?
A. [Route(“custom/route/{id}”)]
B. [CustomRoute(“custom/route/{id}”)]
C. [HttpRoute(“custom/route/{id}”)]
D. [UrlRoute(“custom/route/{id}”)]
Q.41 How can you enable attribute routing in an ASP.NET MVC application?
A. Add routes.MapMvcAttributeRoutes() in RouteConfig.cs
B. Set EnableAttributeRouting to true in web.config
C. Use the [EnableRouting] attribute on controllers
D. Call AttributeRouting.Enable() in Global.asax
Q.42 How does attribute routing differ from convention-based routing in ASP.NET MVC?
A. Attribute routing uses attributes to define routes directly on actions
B. Attribute routing is defined in the RouteConfig.cs file
C. Convention-based routing does not use attributes
D. Convention-based routing is more flexible
Q.43 What is URL rewriting used for in ASP.NET?
A. To shorten URLs
B. To convert dynamic URLs into static ones
C. To encrypt URLs
D. To improve URL readability and SEO
Q.44 Which method is used to add a new route in RouteConfig.cs in ASP.NET MVC?
A. MapRoute()
B. AddRoute()
C. DefineRoute()
D. CreateRoute()
Q.45 What attribute can be used to define a custom route in ASP.NET MVC?
A. [Route]
B. [HttpGet]
C. [HttpPost]
D. [RouteConfig]
Q.46 What is the main purpose of routing in ASP.NET MVC?
A. To manage user sessions
B. To direct URLs to the appropriate controller actions
C. To handle database connections
D. To enhance security
Q.47 What is the purpose of the [HandleError] attribute in ASP.NET MVC?
A. To log errors
B. To handle errors and exceptions
C. To debug the application
D. To route errors to a different controller
Q.48 How can you handle exceptions in an ASP.NET MVC application?
A. Using try-catch blocks
B. Using the HandleError attribute
C. Using custom error pages in web.config
D. Using global error handling middleware
Q.49 Which tool can be used to debug ASP.NET MVC applications?
A. Fiddler
B. Postman
C. Browser Developer Tools
D. Visual Studio Debugger
Q.50 How do you perform model validation in ASP.NET MVC before saving data?
A. Use the ValidateModel() method
B. Use the ModelState.IsValid property
C. Use the ModelValidation() method
D. Use the DataAnnotations.Validate() method
Q.51 How can you specify a required field in a model using data annotations in ASP.NET MVC?
A. [Required]
B. [Mandatory]
C. [NotNull]
D. [DataRequired]
Q.52 Which method in ASP.NET MVC is used to return JSON data from a controller action?
A. ReturnJson()
B. Json()
C. ReturnAsJson()
D. AsJson()
Q.53 What attribute is used to define a route in ASP.NET MVC?
A. [Route]
B. [HttpRoute]
C. [ActionRoute]
D. [WebRoute]
Q.54 What does the View component represent in MVC?
A. Data Layer
B. User Interface
C. Business Logic
D. Controller Logic
Q.55 In ASP.NET MVC, which method is commonly used to pass data from the Controller to the View?
A. ViewData
B. ViewBag
C. TempData
D. ViewModel
Q.56 What is the main purpose of the Controller in the MVC pattern?
A. To handle database connections
B. To manage user interface
C. To handle user input and interactions
D. To manage stylesheets
Q.57 Which component in MVC handles the business logic?
A. Model
B. View
C. Controller
D. Handler
Q.58 What does MVC stand for in ASP.NET MVC?
A. Model-View-Controller
B. Model-Visual-Controller
C. Module-View-Controller
D. Model-View-Compiler
Q.59 Which attribute in the web.config file can be used to customize error pages in ASP.NET?
A. <customErrors>
B. <errorPages>
C. <pages>
D. <errors>
Q.60 What is the purpose of the Debug mode in ASP.NET?
A. To optimize the application
B. To deploy the application
C. To allow for better error tracking and debugging
D. To manage user sessions
Q.61 Which attribute is used to define a route in Web API?
A. [Route]
B. [HttpGet]
C. [WebRoute]
D. [ApiRoute]
Q.62 What is the default return format of Web API when a request is made?
A. XML
B. JSON
C. HTML
D. Plain text
Q.63 Which HTTP method is used to retrieve data in Web API?
A. GET
B. POST
C. PUT
D. DELETE
Q.64 What is the primary purpose of ASP.NET Web API?
A. To create dynamic web pages
B. To build RESTful services
C. To manage databases
D. To handle client-side scripting
Q.65 How can you handle exceptions securely in an ASP.NET application?
A. By showing detailed error messages
B. By logging errors and showing generic error pages
C. By ignoring errors
D. By redirecting to a static page
Q.66 Which tool can be used to scan for security vulnerabilities in an ASP.NET application?
A. Fiddler
B. Postman
C. OWASP ZAP
D. Route Debugger
Q.67 How do you hash passwords in ASP.NET Identity?
A. Using the SHA1 class
B. Using the MD5 class
C. Using the PasswordHasher class
D. Using the Cryptography class
Q.68 How do you implement role-based authorization in ASP.NET MVC?
A. Using the [Authorize] attribute with roles
B. Using the [Roles] attribute
C. Using the [Allow] attribute
D. Using the [Permissions] attribute
Q.69 How do you enable SSL for an ASP.NET web application?
A. By setting the “requireSSL” attribute in the Web.config file
B. By setting the “secure” attribute in the Global.asax file
C. By using the [RequireSSL] attribute in the Controller
D., By setting the “https” attribute in the RouteConfig
Q.70 Which ASP.NET feature helps in preventing CSRF attacks?
A. ViewState
B. Cookies
C. Request Validation
D. Anti-Forgery Tokens
Q.71 What is SQL Injection and how can it be prevented in ASP.NET?
A. A method to speed up SQL queries; Use faster hardware
B. A technique to manipulate SQL queries; Use parameterized queries
C. A way to manage database schema; Use database triggers
D. A process to optimize SQL performance; Use indexing
Q.72 What is the primary purpose of using SSL/TLS in web applications?
A. To improve page load speed
B. To secure data transmission
C. To enhance SEO
D. To manage cookies
Q.73 What is Cross-Site Scripting (XSS) in the context of web security?
A. An attack that involves injecting malicious scripts into a website
B. A method for encrypting data
C. A technique for optimizing web performance
D. A way to manage user sessions
Q.74 What is the role of the Web.config file in ASP.NET security?
A. To store user credentials
B. To configure security settings
C. To manage database connections
D. To handle error pages
Q.75 What is the purpose of Forms Authentication in ASP.NET?
A. To manage user roles
B. To encrypt data
C. To authenticate users based on credentials
D. To manage sessions
Q.76 How can you handle database connection errors in ADO.NET?
A. By using try-catch blocks
B. By using error pages
C. By using validation controls
D. By using logging libraries
Q.77 Which tool can be used to profile database queries in ASP.NET?
A. Fiddler
B. Postman
C. SQL Profiler
D. Browser Developer Tools
Q.78 How do you retrieve a single value from a database using SqlCommand?
A. command.ExecuteScalar();
B. command.ExecuteSingle();
C. command.ExecuteValue();
D. command.ExecuteCommand();
Q.79 How do you execute a non-query SQL command using SqlCommand in ADO.NET?
A. command.ExecuteNonQuery();
B. command.RunCommand();
C. command.ExecuteCommand();
D. command.RunNonQuery();
Q.80 How do you open a database connection using SqlConnection in ADO.NET?
A. connection.Start();
B. connection.Open();
C. connection.Connect();
D. connection.Begin();
Q.81 What is Entity Framework in ASP.NET?
A. A database management tool
B. A client-side scripting framework
C. An ORM (Object-Relational Mapper)
D. A server-side state management tool
Q.82 What is the purpose of the ConnectionString in ADO.NET?
A. To specify the database schema
B. To define the structure of the DataSet
C. To provide the necessary information to connect to a database
D. To manage transactions
Q.83 Which method of the SqlCommand object is used to execute a SELECT query?
A. ExecuteScalar()
B. ExecuteNonQuery()
C. ExecuteReader()
D. ExecuteCommand()
Q.84 What is the purpose of the SqlCommand object in ADO.NET?
A. To store data in memory
B. To execute SQL queries and commands
C. To connect to the database
D. To manage transactions
Q.85 Which object in ADO.NET is used to hold a table of data in memory?
A. DataReader
B. DataSet
C. DataTable
D. DataAdapter
Q.86 What is ADO.NET used for in ASP.NET?
A. Managing user sessions
B. Handling HTTP requests
C. Accessing and manipulating data in databases
D. Managing application settings
Q.87 What tool can you use to debug issues with cookies in an ASP.NET application?
A. Visual Studio Debugger
B. Browser Developer Tools
C. Route Debugger
D. SQL Profiler
Q.88 How can you inspect the contents of Session State while debugging?
A. Using the Visual Studio debugger
B. Using browser developer tools
C. Using Fiddler
D. Using Postman
Q.89 How do you remove an item from Session State in ASP.NET?
A. Session.Remove(“key”);
B. Session.Delete(“key”);
C. Session.Clear(“key”);
D. Session.Erase(“key”);
Q.90 How can you enable ViewState for a TextBox control in ASP.NET?
A. TextBox.EnableViewState = true;
B. TextBox.ViewState = true;
C. TextBox.SaveState = true;
D. TextBox.PersistState = true;
Q.91 What is the purpose of the customErrors element in Web.config?
A. To customize the appearance of a website
B. To manage user roles
C. To define custom error pages
D. To handle database queries
Q.92 What is the role of the Global.asax file in error handling?
A. To define CSS styles
B. To handle application-level events and errors
C. To manage database connections
D. To optimize performance
Q.93 What is a common method for handling exceptions in ASP.NET?
A. Using if-else statements
B. Using try-catch blocks
C. Using loops
D. Using break statements
Q.94 What is the primary purpose of error handling in ASP.NET?
A. To enhance performance
B. To manage user sessions
C. To handle and log application errors
D. To manage databases
Q.95 How do you handle errors when creating a user in ASP.NET Identity?
A. By logging the errors
B. By showing detailed error messages to the user
C. By using try-catch blocks and checking IdentityResult
D. By ignoring the errors
Q.96 Which tool can be used to monitor and debug authentication issues in ASP.NET Identity?
A. Fiddler
B. Postman
C. SQL Profiler
D. Browser Developer Tools
Q.97 How do you verify a user password in ASP.NET Identity?
A. userManager.VerifyPassword(user, password);
B. signInManager.CheckPassword(user, password);
C. userManager.CheckPasswordAsync(user, password);
D. identityManager.VerifyPasswordAsync(user, password);
Q.98 How do you add a user to a role in ASP.NET Identity?
A. roleManager.AddUserToRole(user, role);
B. userManager.AddToRoleAsync(user, role);
C. signInManager.AddToRoleAsync(user, role);
D. identityManager.AddUserToRoleAsync(user, role);
Q.99 How do you create a new user in ASP.NET Identity?
A. userManager.AddUserAsync(user);
B. userManager.CreateAsync(user, password);
C. userManager.AddAsync(user);
D. userManager.NewUserAsync(user, password);
Q.100 How does ASP.NET Identity store user information by default?
A. In a SQL database
B. In memory
C. In a text file
D. In an XML file
Q.101 What is the purpose of the SignInManager class in ASP.NET Identity?
A. To create roles
B. To manage user sign-ins
C. To handle database connections
D. To manage user sessions
Q.102 Which class is used to manage users in ASP.NET Identity?
A. UserManager
B. RoleManager
C. SignInManager
D. IdentityManager
Q.103 What is a role in ASP.NET Identity?
A. A type of database connection
B. A type of user
C. A set of permissions assigned to a user
D. A method of session management
Q.104 What is the primary purpose of ASP.NET Identity?
A. To manage sessions
B. To handle HTTP requests
C. To provide authentication and authorization
D. To manage database connections
Q.105 What is a recommended approach to troubleshoot connection issues in SignalR?
A. By checking server logs
B. By enabling detailed client-side logging
C. By using browser developer tools
D. By testing different transport methods
Q.106 Which tool can be used to monitor SignalR traffic?
A. Fiddler
B. Postman
C. SQL Profiler
D. Browser Developer Tools
Q.107 How do you handle disconnections in SignalR?
A. By overriding the OnDisconnectedAsync method
B. By using the OnDisconnect event
C. By implementing the IDisconnectHandler interface
D. By using the Disconnect attribute
Q.108 How do you call a client method from a SignalR Hub using a specific client ID?
A. Clients.Caller.methodName()
B. Clients.Client(“clientId”).methodName()
C. Clients.Group(“groupName”).methodName()
D. Clients.All.methodName()
Q.109 How do you define a Hub in SignalR?
A. public class MyHub : SignalRHub
B. public class MyHub : Hub
C. public class MyHub : SignalR.Connection
D. public class MyHub : SignalR.Component
Q.110 What is the main use of the PersistentConnection class in SignalR?
A. To manage database connections
B. To create reusable connections that handle low-level communication details
C. To optimize performance
D. To manage user authentication
Q.111 How does SignalR handle fallback transport methods?
A. By using only WebSockets
B. By disconnecting the client
C. By automatically switching to supported transport methods
D. By throwing an error
Q.112 Which protocol is preferred for SignalR when available?
A. Long Polling
B. WebSockets
C. Server-Sent Events
D. HTTP
Q.113 What is a Hub in SignalR?
A. A database component
B. A security feature
C. A server-side component for handling client connections
D. A caching mechanism
Q.114 What is the primary purpose of SignalR in ASP.NET?
A. To manage databases
B. To create real-time web applications
C. To handle user authentication
D. To optimize performance
Q.115 How can you enable tracing in a Web API application?
A. By using the System.Diagnostics.Trace class
B. By setting Trace=”true” in Web.config
C. By adding a trace listener in Global.asax
D. By using tracing middleware
Q.116 Which tool can be used to test Web API endpoints?
A. Fiddler
B. Postman
C. SQL Profiler
D. Route Debugger
Q.117 How do you handle exceptions in a Web API?
A. By using try-catch blocks
B. By using exception filters
C. By using middleware
D. All of the above
Q.118 How do you specify an HTTP GET method in a Web API controller?
A. [HttpGet]
B. [Get]
C. [HttpVerb(“GET”)]
D. [HttpRetrieve]
Q.119 How do you return a JSON response from a Web API controller action?
A. return Json(object);
B. return new JsonResult(object);
C. return Ok(object);
D. return JsonResponse(object);
Q.120 How do you ensure security in a Web API?
A. By using SSL
B. By storing passwords in plaintext
C. By disabling authentication
D. By allowing all IPs
Q.121 What is a common technique to improve database query performance in ASP.NET?
A. Use inline queries
B. Use complex queries
C. Use parameterized queries
D. Use indexing
Q.122 How can you identify performance bottlenecks in an ASP.NET application?
A. By reviewing code for syntax errors
B. By using performance profiling tools
C. By checking the application logs
D. By using a higher bandwidth connection
Q.123 Which tool is commonly used to analyze the performance of an ASP.NET application?
A. Fiddler
B. Postman
C. SQL Profiler
D. Visual Studio Profiler
Q.124 How do you implement asynchronous programming in ASP.NET to improve performance?
A. Use the async and await keywords
B. Use synchronous methods
C. Use the Thread.Sleep method
D. Use the Task.Delay method
Q.125 How do you enable output caching for a page in ASP.NET?
A. Add the [OutputCache] attribute to the page directive
B. Set cache=”true” in the web.config
C. Use the Cache object
D. Enable caching in IIS
Q.126 What is the purpose of output caching in ASP.NET?
A. To store user sessions
B. To reduce server load by caching the generated output of pages
C. To handle authentication
D. To manage database connections
Q.127 Which of the following can help reduce the load time of an ASP.NET web page?
A. Using inline CSS
B. Using image sprites
C. Using multiple external CSS files
D. Using large images
Q.128 What is the primary goal of performance tuning in ASP.NET applications?
A. To improve code readability
B. To optimize application speed and efficiency
C. To enhance security
D. To simplify deployment
Q.129 What is the purpose of the Application Pool in IIS?
A. To manage multiple websites
B. To isolate applications for better security and reliability
C. To serve static files
D. To handle DNS resolution
Q.130 How can you troubleshoot HTTP 500 errors in an ASP.NET application hosted on IIS?
A. Check the application code
B. Review the IIS logs
C. Use browser developer tools
D. Restart the application pool
Q.131 Which tool can be used to diagnose deployment issues in ASP.NET applications?
A. Visual Studio Debugger
B. Web Deploy
C. Event Viewer
D. Postman
Q.132 How do you configure a custom domain for an ASP.NET application in IIS?
A. Edit the hosts file
B. Add a binding for the domain in IIS
C. Modify the web.config file
D. Change the application settings in Visual Studio
Q.133 How do you publish an ASP.NET application to IIS using Visual Studio?
A. Use the “Compile” option
B. Use the “Build” option
C. Use the “Publish” option
D. Use the “Run” option
Q. 134 What is the role of IIS in hosting ASP.NET applications?
A. To manage databases
B. To handle user authentication
C. To serve web applications to users
D. To compile code
Q.135 What is the benefit of using a Web Deploy package for ASP.NET applications?
A. Simplifies deployment process
B. Improves code readability
C. Enhances security
D. Reduces development time
Q.136 What is the primary purpose of the web.config file in deployment?
A. To manage database connections
B. To configure application settings
C. To handle user sessions
D. To optimize performance
Q.137 What is a mock object and how is it used in unit testing?
A. A real object used to test performance
B. A simulated object that mimics the behavior of real objects
C. A database connection
D. A security token
Q.138 How can you run unit tests in Visual Studio?
A. Using the Command Line
B. Using the Test Explorer window
C. Using the Solution Explorer window
D. Using the Output window
Q.139 Which tool is commonly used for debugging unit tests in ASP.NET?
A. Visual Studio Debugger
B. Postman
C. SQL Profiler
D. Fiddler
Q.140 How do you assert that a method throws an exception in NUnit?
A. Assert.Throws(() => method());
B. Assert.Catch(() => method());
C. Assert.Error(() => method());
D. Assert.Fails(() => method());
Q.141 How do you create a unit test method in MSTest?
A. [Test] public void TestMethod() {}
B. [TestMethod] public void TestMethod() {}
C. [UnitTest] public void TestMethod() {}
D. [TestClass] public void TestMethod() {}
Q.142 What is integration testing in the context of ASP.NET?
A. Testing individual components
B. Testing the user interface
C. Testing the interaction between different components
D. Testing network security
Q.143 Which framework is commonly used for unit testing in ASP.NET?
A. NUnit
B. MSTest
C. XUnit
D. All of the above
Q.144 What is the primary purpose of unit testing in ASP.NET?
A. To test the user interface
B. To test individual components of the application
C. To test database performance
D. To test network security
Q.145 How do you use the Elmah library for error handling in ASP.NET?
A. By configuring Elmah in the web.config
B. By writing custom error handling code
C. By enabling Elmah in IIS
D. By adding Elmah to the Global.asax
Q.146 What is the use of the Debug class in ASP.NET?
A. To compile the application
B. To optimize performance
C. To provide debugging and tracing methods
D. To manage database connections
Q.147 How can you enable debugging in an ASP.NET application?
A. By setting debug=”true” in the web.config
B. By setting debug=”false” in the web.config
C. By enabling debugging in IIS
D. By using the Debug class
Q.148 Which tool is commonly used for debugging ASP.NET applications?
A. Fiddler
B. Postman
C. Visual Studio Debugger
D. SQL Profiler
Q.149 How can you handle an application error globally in ASP.NET?
A. By using try-catch blocks in every method
B. By handling the Application_Error event in Global.asax
C. By setting custom error pages in the web.config
D. By logging the error to a database
Q.150 How do you log an error using the Trace class in ASP.NET?
A. Trace.Write(“Error”);
B. Trace.Log(“Error”);
C. Trace.Error(“Error”);
D. Trace.Add(“Error”);