Setup:
I am using the Html.ActionLink
helper to create a tags to my action, Reset
, in the controller PasswordReset
, in the area Admin
.
Html.ActionLink calls (EDITED, but still no joy):
The calls to Html.ActionLink are in a foreach loop (html simplified):
foreach(var item in Model.Entities)
{
<p>
@Html.ActionLink("Reset Password",
"Reset",
"PasswordReset",
new {area="Admin",
userName=item.UserName,
email=item.Email,
roles=item.Roles},
null)
</p>
}
My action:
[HttpGet]
public virtual ActionResult Reset(string userName, string email, string roles)
{
if (string.IsNullOrEmpty(userName)) throw new ApplicationException("Invalid Username!");
var ue = new UsernameEmailDTO
{
UserName = userName,
Email = email,
Roles = roles
};
return View(ue);
}
Route:
context.MapRoute(
"Admin_PasswordReset",
"Admin/Password/Reset/{userName}",
new { controller = "PasswordReset", action="Reset", email = UrlParameter.Optional, roles = UrlParameter.Optional }
);
Problem:
I can call the action directly using the route.
However, my action link just produces a link that points to the current page.
So there has to be an error in my Html.ActionLink code.
But what?!
Very frustrating as I thought I was over this variety of pain barrier.