1

I want to pass an id like a string to my action method , I am doing like this

 <li>@Html.ActionLink("Nokia Lumia Series", "Mobiles", "Products", new { id = "Lumia" })

and here is my action method

public ActionResult Mobiles(string name)
        {
            return View();
        }

but it is not going on that action and this url is shown in browser tab

http://mymobiles.com/Home/Mobiles?Length=8

What I am doing wrong here??

1 Answer 1

2

You are using an incorrect overload of ActionLink. You should use this overload:

public static MvcHtmlString ActionLink(
    this HtmlHelper htmlHelper,
    string linkText,
    string actionName,
    string controllerName,
    Object routeValues,
    Object htmlAttributes
)

Your code then becomes, I also changed your parameter name to make it more clear:

@Html.ActionLink("Nokia Lumia Series", "Mobiles", "Products", new { name = "Lumia" }, null)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.