I'm attempting to use @Url.Action to pass multiple parameters through the URL in such a way I can read in the extra parameters using the RouteAttribute
<li><a class="survey-button" href="
@Url.Action("Survey",(Model.SurveyID).ToString(),"Page"(Model.PageNumber).ToString())
">Previous</a></li>
//localhost:8080/Survey/1/Page/1
[Route("Survey/{surveyID}/Page/{pageNumber}")]
public ActionResult Page(int surveyID, int pageNumber)
{
...
I realize I can pass these via a query string, but for cleanliness reasons this is not preferred.
You need to wrap your parameters in a RouteValueDictionary
or an anonymous object (easier). I am assuming that your controller name is SurveyController
.
@Url.Action("Page", "Survey", new {surveyId = Model.SurveyId, pageNumber = Model.PageNumber})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.