2

during code writing I encountered a problem which I do not know how to solve. I need to send some parameters into Index using Html.ActionLink but if I use this type of code i send only "Name" and "true" but no parameters from Model.state:

 @Html.ActionLink("Name", "Index", "Home", new { Model.state, sortBy = "Name", isNameSortedDescending = true })

However, if I use this kind of code I send Model.state (3 x true) without "Name" and "true":

@Html.ActionLink("Name", "Index", "Home",  Model.state, new { sortBy = "Name", isNameSortedDescending = true })

Does someone know how to send all of this parameters?

1
  • Can you please share with us your HomeController's Index action signature? Commented Jun 30, 2020 at 9:44

1 Answer 1

2

ActionLink has several overloads.

Your first attempt matches to the following overload:

  • linkText: Name
  • actionName: Index
  • controllerName: Home
  • routeValues: new { Model.state, sortBy = "Name", isNameSortedDescending = true }

Your second attempt matches to the following overload:

  • linkText: Name
  • actionName: Index
  • controllerName: Home
  • routeValues: Model.State
  • htmlAttributes: new { sortBy = "Name", isNameSortedDescending = true }

You would need to use the first one to pass (only) routing data.

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.