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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:56:57+00:00 2026-06-16T14:56:57+00:00

I have problem with optional parameter for one of the routes. Route looks like

  • 0

I have problem with optional parameter for one of the routes. Route looks like that:

            routes.MapRoute(
            "VideoList", // Route name
            "VideoList/{page}", // URL with parameters
            new { controller = "Video", action = "VideoList" , page = UrlParameter.Optional}
        );

It works fine when used first time:

@Html.RouteLink("Video", "VideoList", null, new { id = "idVideo", @class = "menu-item" })

Controller action gets NULL in place of page parameter and I handle rest within the action.

Then, I play with the web page and I try this same routing again, this time specifying ‘page’ param, lets say it carries value 7.

@Html.RouteLink("Video", "VideoList", new { page = 7 }, new { id = "idVideo", @class = "menu-item" })

It works as expected as well, but when again I try to use route without ‘page’ specified it carries because of some reason again value used for this parameter last time, which is 7

Not sure why. I would expect it to work as first time by passing null to the controller for this parameter

I will provide more info if needed.

  • 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-06-16T14:56:58+00:00Added an answer on June 16, 2026 at 2:56 pm

    That’s how routing works. You need to explicitly set the parameter if you don’t want the RouteLink fetching it from the current request route values:

    @Html.RouteLink("Video", "VideoList", new { page = "" }, new { id = "idVideo" })
    

    This will always generate /VideoList url. If you don’t explicitly set the page parameter to an empty string (as in your first example), then the helper will analyze the current request routing values when generating the link. And if the current url is /VideoList/7, then the helper will preserve all route values and generate /VideoList/7.

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

Sidebar

Related Questions

I have route defined as routes.MapRoute( Company, // Route name Company/{companyname}, // URL with
I have a function that looks like the following, with a whole lot of
I have created a stored procedure, with one optional parameter, which defaults to NULL
I have the following route definitions in my MVC3 website: routes.MapRoute( FB, // Route
I have problem with UIWebView delay when the load image from url. In my
I have MVC3 application that runs under mono on linux. I have this route:
I have an interesting problem that seems to be eluding me. Mono's xsp4 only
consider following url: http://sitename.com/School/Admin/PageViewer i have a subfolder in School named UserFiles that contains
I am working on a project, where I have used the default routing routes.MapRoute(
I have an application that I am using a global route to query for

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.