2

I have a route that I can access using the following pattern

ResponsesTotals/Show/1 ResponsesTotals/Show/2 ..... ..... ResponsesTotals/Show/n 

From a different view, I need to list names and when the user clicks on them I want to direct them to the routes showing above.

Here is what I have tried

@model List<Proj.Model.Survey> <ul> @foreach (var survey in Model) { <li>@Html.ActionLink(survey.Name, "Show", "ResponsesTotals", new { SurveyId = survey.Id })</li> } </ul> 

But that for some reason is generating wrong URLs. Here is what is being generated

ResponsesTotals/Show?Length=15 

How can I pass a parameter to the link?

1 Answer 1

2

Add null for the last parameter so you hit the correct method:

@Html.ActionLink(survey.Name, "Show", "ResponsesTotals", new { SurveyId = survey.Id },null) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.