I am attempting to pass a string as an action parameter to Url.Action using the following line:
url = '@Url.Action(nameof(Controllers.DailyController.UserBreakEnd), "Daily", new { breakToEnd = 1, confirmation = "BreakCanceled" })';
The breakToEnd parameter is coming through in the function, but confirmation is not. Am I passing the string incorrectly?
Also, when I do it like this, both parameters come through:
url = '@Url.Action(nameof(Controllers.DailyController.UserBreakEnd))?breakToEnd=@(Model.MessageType == "BreakUnder" ? 1 : 2)&Confirmation=BreakCanceled';
Does anyone see what I am doing wrong?
It seems as though instead of placing an & symbol in between the parameters in the URL string that was generated, this was putting &
between them.
The issue was resolved by surrounding the Url.Action with Html.Raw, like so:
url = '@Html.Raw(Url.Action(nameof(Controllers.DailyController.UserBreakEnd), "Daily", new { breakToEnd = 1, confirmation = "BreakCanceled" }))';
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.