What should you do?

You are developing an ASP.NET MVC 2 Web application that displays product details. The global.asax.cs file contains the following code segment
01 public static void registerRoutes(RouteCollection routes)
02 {
03 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
04 routes.MapRoute("Default", "{controller}/{action}/{id}", new {controller = "Home", action = "index", id = UrlParameter.Optional});
05 }
The URL "/products/PRODUCTNAME", where PRODUCTNAME is the name of the product, must give details for the product that is stored in a Microsoft SQL Server database.
You need to ensure that the routes are registered correctly.
What should you do?
A. Replace line 04 with the following code segment
routes.MapRoute("products/{productName}, "ProductDetails", new {controller = "Products", action = "index", productName = UrlParameter.Optional});
B. Add the following code segment between lines 04 and 05
routes.MapRoute("ProductDetails, "products/{productName}", new {controller = "Products", actions="index", productName = UrlParameter.Optional});
C. Replace lines 03 and 04 with the following code segment
routes.MapRoute("products/{productName}", "ProductDetails", new {controller ="Products", action="Index", productName=UrlParameter.Optional});
D. Add the following code segment between lines 03 and 04.
routes.MapRoute("ProductDetails","products/{productName}", new {controller="products", action ="Index", productName = UrlParameter.Optional});

microsoft-exams

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.