in my asp.net razor page i have a dynamically rendered button:
<a href="@Url.Action("AddSubSub", "GlobalTagging", new { idOfSubsub = 3});">Add Subsub</a>
which fires this function:
public ActionResult AddSubSub(int? idOfSubsub)
{
return RedirectToAction("Index", new { searchword = "" });
}
however, idOdSubsub is always returned as null, never as "3". Which i gave it in the <a>.
Why isnt the param handed over?
>Solution :
I just tested this and the problem is the semicolon at the end of your href, with the semicolon it produced an href of: /GlobalTagging/AddSubSub?idOfSubsub=3; (Doesn’t work):
<a href="@Url.Action("AddSubSub", "GlobalTagging", new { idOfSubsub = 3});">Add Subsub</a>
If you remove the semicolon, it works and produces an href of: /GlobalTagging/AddSubSub?idOfSubsub=3 (Works):
<a href="@Url.Action("AddSubSub", "GlobalTagging", new { idOfSubsub = 3})">Add Subsub</a>