Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3788506
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:00:37+00:00 2026-05-19T12:00:37+00:00

I received the following problem on the MCTS exam. The book says the answer

  • 0

I received the following problem on the MCTS exam. The book says the answer is C, but I thought B would be the correct answer. Why is it C?

You create a new ASP.NET MVC 2 Web application. The following default routes are created in
the Global.asax.cs file. (Line numbers are included for reference only.)

01 public static void RegisterRoutes(RouteCollection routes)
02 {
03 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
04
05 routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" } );
06 }

You implement a controller named HomeController that includes methods with the following
signatures.

public ActionResult Index() 
public ActionResult Details(int id) 
public ActionResult DetailsByUsername(string username) 

You need to add a route to meet the following requirements:

  • The details for a user must to be displayed when a user name is entered as the path by invoking the DetailsByUsername action.

  • User names can contain alphanumeric characters and underscores, and can be between 3 and 20 characters long. What should you do?

A. Replace line 05 with the following code segment.

routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "DetailsByUsername", id = "" } );

B. Replace line 05 with the following code segment.

routes.MapRoute( "Default", "{controller}/{action}/{username}", new { controller = "Home", action = "DetailsByUsername", username = "" }, new { username = @"\w{3,20}" } );

C. At line 04, add the following code segment.

routes.MapRoute( "Details by Username", "{username}", new { controller = "Home", action = "DetailsByUsername" }, new { username = @"\w{3,20}" } );

D. At line 04, add the following code segment.

routes.MapRoute( "Details by Username", "{id}", new { controller = "Home", action = "DetailsByUsername" }, new { id = @"\w{3,20}" } );
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:00:37+00:00Added an answer on May 19, 2026 at 12:00 pm

    When an ASP.NET MVC route looks for an action to map to, it takes several things into account:

    1. The action name (Non-case sensitive)
    2. The parameter names (non-case sensitive)
    3. Whether or not the constraints are matched on the route.

    Because of that, if you want a route that matches the criteria you listed, this route would be the correct answer:

    routes.MapRoute( 
        "Details by Username", 
        "{username}", 
        new { controller = "Home", action = "DetailsByUsername" }, 
        new { username = @"\w{3,20}" } 
    );
    

    A URL with this structure would match that route for the following reasons:

    http://example.com/my_user_name
    
    1. The action name matches,
    2. It’s looking for a parameter in the action called ‘username’, and
    3. The criteria for non-alphanumeric characters is met.

    C is the correct answer as it adds to the current routes.

    Answer B replaces the existing route definition, thus preventing the default routing to the Home controller Index action.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently received a downvote for using the following in a recent answer :
I ran JSLint on some inherited code, and received the following: Problem at line
Following the hint I received on my previous question I come across another problem.
I received the following error when I tried to run a C# WinForms application
I received the following crash report (truncated) Exception Type: EXC_CRASH (SIGSEGV) Exception Codes: 0x00000000,
I received this error on following code.Is this + sign is not available in
I received DateTime String from Fedex in following format 2012-06-22T21:39:48-05:00 I want to convert
Today I received a crash report because in the following snippet w and/or h
I have the following table: $sql = CREATE TABLE received_queries ( sender_screen_name varchar(50), text
So I'm using the following php code to set variables that are received from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.