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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:56:09+00:00 2026-06-03T02:56:09+00:00

I have a controller method that looks like public ViewResult Index(string id, string participant=,

  • 0

I have a controller method that looks like

public ViewResult Index(string id, string participant="", string flagged = "")

id is a route value in my global.asax for this controller. I want to pass in the other values as regular arguments so the link would look like

.../controller/Index/id?participant=yes&flagged=no

Is there a way to generate a link like this using Razor script in MVC 3?

  • 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-03T02:56:11+00:00Added an answer on June 3, 2026 at 2:56 am

    You could pass all parameters in the routeValues argument of the ActionLink method:

    @Html.ActionLink(
        "go to index",                  // linkText
        "index",                        // actionName
        new {                           // routeValues
            id = "123", 
            participant = "yes", 
            flagged = "no" 
        }
    )
    

    Assuming default routing setup this will generate:

    <a href="/Home/index/123?participant=yes&amp;flagged=yes">go to index</a>
    

    UPDATE:

    To further elaborate on the comment you have posted, if the ActionLink generated an url with Length=6 for example this means that you have used the wrong overload. For example this is wrong:

    @Html.ActionLink(
        "go to index",             // linkText
        "index",                   // actionName
        "home",                    // routeValues
        new {                      // htmlAttributes
            id = "123", 
            participant = "yes", 
            flagged = "no" 
        }
    )
    

    It is obvious why this is wrong from the comments I’ve put along each parameter name. So make sure you are carefully reading the Intellisense (if you are lucky enough to have Intellisense working in Razor :-)) to pick the correct overload of the helper methods.

    The correct overload in the case you want to specify a controller name is the following:

    @Html.ActionLink(
        "go to index",             // linkText
        "index",                   // actionName
        "home",                    // controllerName
        new {                      // routeValues
            id = "123", 
            participant = "yes", 
            flagged = "no" 
        },
        null                       // htmlAttributes
    )
    

    Notice the null that is passed as last argument. That’s what corresponds to the htmlAttributes parameter.

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

Sidebar

Related Questions

I have a controller method that looks like this: [AcceptGet] public ActionResult Index(SecurityMatrixIndexViewModel model)
I have an action method that looks like this: public ActionResult Index(string message) {
I have a controller method in ASP.NET MVC that looks like this: public ActionResult
I have a basic Spring MVC controller that looks like this: @Controller public void
In ASP.NET MVC I have a controller that looks somehow like this: public class
I have a controller method that is a little something like this: def suggestions
I have a controller that looks like this for importing xml to my site:
I have a Security class that looks like this: package controllers; import play.Logger; public
I have a controller method that returns a jSON object and in one calling
i have a quetion about MVC routing. I have a controller method that is

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.