MCTS ASP.NET Web Applications 2 — Questions and Answers
Question 1: Which ASP.NET membership provider stores user credentials in a SQL Server database by default?
- ActiveDirectoryMembershipProvider
- SqlMembershipProvider (Correct answer)
- WindowsTokenRoleProvider
- XmlMembershipProvider
Correct answer: SqlMembershipProvider
SqlMembershipProvider is the default ASP.NET membership provider that stores user credentials and profile data in a SQL Server database.
Question 2: In ASP.NET, what is the purpose of the HttpModule interface?
- To generate HTTP responses for specific URL patterns
- To intercept and process HTTP requests across all requests in the pipeline (Correct answer)
- To define custom server controls rendered as HTML
- To configure connection strings in web.config
Correct answer: To intercept and process HTTP requests across all requests in the pipeline
HttpModules plug into the ASP.NET request pipeline and can handle events fired for every request, enabling cross-cutting concerns like authentication and logging.
Question 3: What does the OutputCache directive's VaryByParam attribute control?
- Which user roles receive cached responses
- Which query string or POST parameters create separate cache entries (Correct answer)
- How long the cached output is stored on the server
- Whether the cache is stored on the client or server
Correct answer: Which query string or POST parameters create separate cache entries
VaryByParam instructs ASP.NET to maintain distinct cached versions of a page output for each unique combination of specified query string or form parameters.
Question 4: Which GridView event should you handle to perform custom logic when a row is being deleted?
- RowDataBound
- RowDeleting (Correct answer)
- RowCommand
- RowEditing
Correct answer: RowDeleting
The RowDeleting event fires before the delete operation executes, allowing you to cancel or customize the deletion logic.
Question 5: In ASP.NET Web Forms, what is the role of the IsPostBack property?
- Determines if the current request came from an authenticated user
- Indicates whether the page is being loaded in response to a client postback (Correct answer)
- Checks if ViewState is enabled for the current page
- Verifies that cross-site request forgery protection is active
Correct answer: Indicates whether the page is being loaded in response to a client postback
IsPostBack returns true when the page is loaded because a user action triggered a form submission back to the server, helping you avoid re-initializing data on postbacks.
Question 6: Which attribute is applied to an ASP.NET Web API action method to restrict it to HTTP PUT requests only?
- [WebPut]
- [HttpPut] (Correct answer)
- [AcceptVerbs("PUT")]
- [RoutePrefix("PUT")]
Correct answer: [HttpPut]
[HttpPut] is the standard attribute in ASP.NET Web API and MVC to constrain an action method to respond only to HTTP PUT requests.
Question 7: What is the primary difference between Server.Transfer and Response.Redirect in ASP.NET?
- Server.Transfer sends a 302 status code while Response.Redirect processes on the server
- Server.Transfer processes the new page on the server without a round-trip, while Response.Redirect causes the browser to make a new request (Correct answer)
- Response.Redirect preserves the original URL in the browser while Server.Transfer changes it
- Server.Transfer only works with ASPX pages while Response.Redirect works with any URL
Correct answer: Server.Transfer processes the new page on the server without a round-trip, while Response.Redirect causes the browser to make a new request
Server.Transfer internally forwards execution to another ASPX page without a browser round-trip, keeping the original URL in the address bar, whereas Response.Redirect sends a 302 response causing the browser to issue a new GET request.
Which ASP.NET membership provider stores user credentials in a SQL Server database by default?