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 6608819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:39:00+00:00 2026-05-25T19:39:00+00:00

I added routing to my solution in order to have a more user friendly

  • 0

I added routing to my solution in order to have a more user friendly URL in the address bar.

I start the solution and when I rollover my Favorites link, I see the URL …/Affaire/Favorite (picture below). This one is OK for me.

enter image description here

When I rollover my Recycle bin link, I see the URL ../Affaire/Deleted (picture below). This one is OK for me.

enter image description here

Then I click on the Recycle bin link, I navigate to the corresponding page and the URL showed in the address bar is OK for me (picture below).

enter image description here

Next, I rollover the Favorite link again (picture below), I see the URL ../Affaire/Delete?OnlyFavorite=true!! That’s not OK.

enter image description here

The routing is now retrieving an attribute not from my link but from the active URL! This attribute is named OnlyFavorite and I don’t want this attribute. This is the “reflexion”. Notice that all of my routes are using the same controller and the same action but using different attributes for the routes.

Below are some links I used.

Example for navigating to the favorite page:

@Html.ActionLink("Favorites", "SearchAffaires", new { OnlyFavorite = true })

Example for navigating to the recycle bin page:

@Html.ActionLink("Recycle bin", "SearchAffaires", new { StatusCode = "DELETED" })

Here are my routes:

        routes.MapRoute(
        "Affaire Status Open/Closed/Deleted",                                   // Route name
        "{controller}/{StatusCode}",                                            // URL with parameters
        new { action = "SearchAffaires" },                                      // Parameter defaults
        new { controller = "Affaire", StatusCode = "^Open$|^Closed$|^Deleted$" }// Contraints
        );

        routes.MapRoute(
        "Affaire Only Favorite",                                                // Route name
        "{controller}/Favorite",                                                // URL with parameters
        new { action = "SearchAffaires", Page = 1, OnlyFavorite = true },       // Parameter defaults
        new { controller = "Affaire" }                                          // Contraints
        );

Do you have any idea how can I proceed to avoid this behaviour?

I don’t want the routing to get the attribute named OnlyFavorite from my current URL by reflexion. I already try to pass OnlyFavorite=null on the action link but it doesn’t work: the routing says “ok, I don’t have a value for OnlyFavorite on the link itself but I have OnlyFavorite on the URL so I use it!”.

  • 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-25T19:39:01+00:00Added an answer on May 25, 2026 at 7:39 pm

    When you are on the Deleted page, the link is being processed that way because the StatusCode token is equal to Deleted, so the first route is satisfied. Change your link as follows:

    @Html.ActionLink("Favorites", "SearchAffaires", new { StatusCode = String.Empty, OnlyFavorite = true })
    

    UPDATED

    The best solution is to reverse your routes. As a general rule, the most specific routes should always go first, and you should have more generic routes later. Since the “Affaire Only Favorite” route is more specific, it should always go first. If it is the first route satisfied, that should address your issue.

    UPDATE #2

    I ran a test, and all of the links were generated correctly, when I set the routes as follows:

            routes.MapRoute(
                "Affaire Only Favorite",                                       // Route name 
                "Affaire/Favorite",                                            // URL with parameters 
                new { controller = "Affaire", action = "SearchAffaires", 
                    StatusCode = String.Empty, Page = 1, OnlyFavorite = true } // Parameter defaults 
            );
    
            routes.MapRoute(
                "Affaire Status Open/Closed/Deleted",                                    // Route name 
                "{controller}/{StatusCode}",                                             // URL with parameters 
                new { action = "SearchAffaires" },                                       // Parameter defaults 
                new { controller = "Affaire", StatusCode = "^Open$|^Closed$|^Deleted$" } // Constraints 
            );
    

    In addition, the following more generic routes also generated correctly:

            routes.MapRoute(
                "Favorite",                                                    // Route name 
                "{controller}/Favorite",                                       // URL with parameters 
                new { action = "Search", 
                    StatusCode = String.Empty, Page = 1, OnlyFavorite = true } // Parameter defaults 
            );
    
            routes.MapRoute(
                "Status Open/Closed/Deleted",                    // Route name 
                "{controller}/{StatusCode}",                     // URL with parameters 
                new { action = "Search" },                       // Parameter defaults 
                new { StatusCode = "^Open$|^Closed$|^Deleted$" } // Constraints 
            );
    

    For the more generic routes to work, I had to rename the action as Search and I had to change each link from SearchAffaires to Search.

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

Sidebar

Related Questions

I have a simple ASP.NET 3.5 SP1 Web Forms app... I've added the System.Web.Routing
i have added one route and one link and the load time for the
I have added a new route to my routing table: routes.MapRoute( ModuleRoute, // Route
Url routing and IIS7 03-24-2011 04:24 PM Hi, I have a query regarding Url
I've just created a fresh ASP.NET MVC 4 solution and have added 3 Areas
I have just added routing in a new asp.net 4 web forms application, and
I added a text file to a testapp's solution and I want to read
I added the columns in the select list to the order by list, but
I added a get_absolute_url function to one of my models. def get_absolute_url(self): return '/foo/bar'
I've a small issue with URL generation & routing under ASP.NET MVC 2. My

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.