What does REST stand for in the context of web services?
a. Representational State Transfer
b. Reliable State Transfer
c. Real-time State Transition
d. Resource State Transfer
Answer: a. Representational State Transfer
Which HTTP method is used to create a new resource in RESTful services?
a. POST
b. GET
c. PUT
d. DELETE
Answer: a. POST
How do you define a route in ASP.NET Core Web API?
a. By using the [Route]
attribute
b. By configuring routes in web.config
c. By using the MapRoute
method
d. By defining routes in Startup.cs
Answer: a. By using the [Route]
attribute
What is the purpose of the HttpGet
attribute in ASP.NET Core Web API?
a. To specify that an action method handles HTTP GET requests
b. To specify that an action method handles HTTP POST requests
c. To configure routing
d. To handle model validation
Answer: a. To specify that an action method handles HTTP GET requests
How can you implement custom routes in ASP.NET MVC?
a. By using the [Route]
attribute on action methods
b. By configuring routes in web.config
c. By using the MapRoute
method
d. By defining routes in Startup.cs
Answer: a. By using the [Route]
attribute on action methods
Which HTTP method is used to update an existing resource in RESTful services?
a. PUT
b. POST
c. GET
d. DELETE
Answer: a. PUT
How can you specify a route parameter in ASP.NET Core Web API?
a. By using curly braces {}
in the route template
b. By using square brackets []
in the route template
c. By using parentheses ()
in the route template
d. By using angle brackets <>
in the route template
Answer: a. By using curly braces {}
in the route template
What is the role of the [ApiController]
attribute in ASP.NET Core Web API?
a. To simplify the controller by automatically handling model validation and binding
b. To configure API routing
c. To manage authentication
d. To handle HTTP requests
Answer: a. To simplify the controller by automatically handling model validation and binding
How do you define a route template that includes a default value in ASP.NET Core?
a. By specifying default values in the route template using {parameter=defaultValue}
b. By configuring default values in web.config
c. By defining default values in the Startup.cs
file
d. By using query string parameters
Answer: a. By specifying default values in the route template using {parameter=defaultValue}
What is the purpose of the RoutePrefix
attribute in ASP.NET Web API?
a. To define a common route prefix for all actions in a controller
b. To specify a specific route for an individual action
c. To manage model binding
d. To configure response formatting
Answer: a. To define a common route prefix for all actions in a controller
How do you handle multiple route templates in ASP.NET Core Web API?
a. By using multiple [Route]
attributes on the same action method
b. By defining multiple routes in web.config
c. By configuring routes in Startup.cs
d. By using query string parameters
Answer: a. By using multiple [Route]
attributes on the same action method
Which HTTP method is typically used to delete a resource in RESTful services?
a. DELETE
b. POST
c. PUT
d. GET
Answer: a. DELETE
What attribute is used to define a route in an ASP.NET MVC application?
a. [Route]
b. [HttpRoute]
c. [HttpGet]
d. [ApiRoute]
Answer: a. [Route]
How can you specify an optional route parameter in ASP.NET Core?
a. By appending a ?
to the parameter in the route template
b. By using square brackets []
in the route template
c. By using parentheses ()
in the route template
d. By defining optional parameters in web.config
Answer: b. By using square brackets []
in the route template
What does the HttpResponseMessage
class represent in ASP.NET Web API?
a. The response message sent to the client, including status code and content
b. The request message received from the client
c. The routing configuration
d. The model binding process
Answer: a. The response message sent to the client, including status code and content
How can you use attribute routing to handle complex route templates in ASP.NET MVC?
a. By applying the [Route]
attribute with a custom route template to action methods
b. By defining complex routes in web.config
c. By using query string parameters
d. By configuring routes in Startup.cs
Answer: a. By applying the [Route]
attribute with a custom route template to action methods
What does the Route
attribute do in ASP.NET Core Web API?
a. It specifies the URL pattern that an action method should respond to
b. It configures authentication for Web API
c. It handles model validation
d. It defines the response format
Answer: a. It specifies the URL pattern that an action method should respond to
How do you create a custom route in ASP.NET MVC?
a. By using the MapRoute
method in RouteConfig.cs
b. By defining routes in web.config
c. By applying the [Route]
attribute to action methods
d. By using query string parameters
Answer: a. By using the MapRoute
method in RouteConfig.cs
What is the purpose of the RouteData
property in ASP.NET MVC?
a. To hold information about the current route, including route values and route name
b. To manage HTTP requests
c. To configure API routing
d. To handle model validation
Answer: a. To hold information about the current route, including route values and route name
How can you set up a default route for a Web API application in ASP.NET Core?
a. By configuring a default route template in Startup.cs
b. By defining routes in web.config
c. By using the [Route]
attribute on controllers
d. By managing routes in appsettings.json
Answer: a. By configuring a default route template in Startup.cs
What attribute is used to specify that an action method in ASP.NET Web API should handle HTTP PATCH requests?
a. [HttpPatch]
b. [Patch]
c. [HttpUpdate]
d. [Update]
Answer: a. [HttpPatch]
How do you ensure that an ASP.NET Core Web API action method only responds to HTTP POST requests?
a. By using the [HttpPost]
attribute
b. By using the [Post]
attribute
c. By using the [HttpMethod]
attribute
d. By using query string parameters
Answer: a. By using the [HttpPost]
attribute
What is the purpose of the RouteCollection
class in ASP.NET MVC?
a. To manage a collection of routes defined for the application
b. To handle model binding
c. To configure response formatting
d. To manage authentication
Answer: a. To manage a collection of routes defined for the application
How can you map a Web API controller to a specific route in ASP.NET Core?
a. By using the [Route]
attribute on the controller class
b. By configuring routes in web.config
c. By defining routes in Startup.cs
d. By using query string parameters
Answer: a. By using the [Route]
attribute on the controller class
What attribute is used to define a Web API route that includes a parameter in ASP.NET Web API?
a. [Route]
b. [ApiRoute]
c. [HttpGet]
d. [HttpPost]
Answer: a. [Route]
How do you handle route constraints in ASP.NET Core Web API?
a. By specifying constraints in the route template using {parameter:constraint}
b. By configuring constraints in web.config
c. By using query string parameters
d. By defining constraints in Startup.cs
Answer: a. By specifying constraints in the route template using {parameter:constraint}
What is the purpose of the RouteValueDictionary
class in ASP.NET MVC?
a. To hold route values and their corresponding keys for route matching
b. To manage HTTP requests
c. To configure response formatting
d. To handle model binding
Answer: a. To hold route values and their corresponding keys for route matching
How do you configure attribute routing in ASP.NET Core?
a. By using the [Route]
attribute on controllers and action methods
b. By defining routes in web.config
c. By using the MapRoute
method in Startup.cs
d. By configuring routes in appsettings.json
Answer: a. By using the [Route]
attribute on controllers and action methods
What is the role of the RoutePrefix
attribute in ASP.NET Web API?
a. To define a common route prefix for all actions in a controller
b. To specify a specific route for an individual action
c. To manage model binding
d. To configure response formatting
Answer: a. To define a common route prefix for all actions in a controller
How do you define a route constraint in ASP.NET Core?
a. By adding constraints in the route template using {parameter:constraint}
b. By configuring constraints in web.config
c. By using query string parameters
d. By defining constraints in Startup.cs
Answer: a. By adding constraints in the route template using {parameter:constraint}
What attribute is used to specify that an action method should handle HTTP PUT requests in ASP.NET Web API?
a. [HttpPut]
b. [Put]
c. [HttpUpdate]
d. [Update]
Answer: a. [HttpPut]
How do you configure a default route in an ASP.NET MVC application?
a. By using the MapRoute
method in RouteConfig.cs
b. By defining routes in web.config
c. By applying the [Route]
attribute to controllers
d. By using query string parameters
Answer: a. By using the MapRoute
method in RouteConfig.cs
What is the purpose of the IActionResult
interface in ASP.NET MVC?
a. To represent various types of results that an action method can return
b. To handle HTTP requests
c. To configure routing
d. To manage authentication
Answer: a. To represent various types of results that an action method can return
How do you configure Web API routes using attribute routing in ASP.NET Core?
a. By applying the [Route]
attribute to controllers and action methods
b. By defining routes in web.config
c. By using query string parameters
d. By configuring routes in Startup.cs
Answer: a. By applying the [Route]
attribute to controllers and action methods
What is the purpose of the RouteCollection
class in ASP.NET MVC?
a. To manage a collection of routes for the application
b. To handle model binding
c. To configure response formatting
d. To manage authentication
Answer: a. To manage a collection of routes for the application
How do you define a route with multiple parameters in ASP.NET Core Web API?
a. By using a route template with multiple parameters in the [Route]
attribute
b. By defining parameters in web.config
c. By using query string parameters
d. By configuring routes in Startup.cs
Answer: a. By using a route template with multiple parameters in the [Route]
attribute
What attribute is used to specify that an action method should handle HTTP DELETE requests in ASP.NET Web API?
a. [HttpDelete]
b. [Delete]
c. [HttpRemove]
d. [Remove]
Answer: a. [HttpDelete]
How do you specify a default route parameter value in ASP.NET MVC?
a. By using {parameter=defaultValue}
in the route template
b. By configuring default values in web.config
c. By using query string parameters
d. By defining default values in Startup.cs
Answer: a. By using {parameter=defaultValue}
in the route template
What does the IActionFilter
interface do in ASP.NET MVC?
a. It allows you to execute code before and after an action method executes
b. It manages HTTP requests
c. It configures API routing
d. It handles model validation
Answer: a. It allows you to execute code before and after an action method executes
How can you use route constraints to ensure a parameter is an integer in ASP.NET Core?
a. By specifying {parameter:int}
in the route template
b. By defining constraints in web.config
c. By using query string parameters
d. By configuring constraints in Startup.cs
Answer: a. By specifying {parameter:int}
in the route template
What is the purpose of the IRouteHandler
interface in ASP.NET MVC?
a. To handle the routing of HTTP requests to the appropriate controllers
b. To manage HTTP responses
c. To handle model binding
d. To configure authentication
Answer: a. To handle the routing of HTTP requests to the appropriate controllers
How do you map routes to action methods in ASP.NET Core?
a. By defining routes in the [Route]
attribute applied to action methods and controllers
b. By using the MapRoute
method in Startup.cs
c. By configuring routes in web.config
d. By using query string parameters
Answer: a. By defining routes in the [Route]
attribute applied to action methods and controllers