I'm trying to call a controller method using an ActionLink. I can access the controller method, and even use css to make the ActionLink look like the button it's supposed to, but I can't pass in parameters - every time I try, I either get an error or the values turn up as null.
These will actually reach the method and hit the break point I set, but without any parameter values.
<p>@Html.ActionLink("Submit Request", "Create", "HomeController", new { @class = "btn btn-primary"})</p>
<p>@Html.ActionLink("Submit Request", "Create", "HomeController", new { @class = "btn btn-primary", title = "hello", description = "world"})</p>
These give me an error as soon as I click on the button, specifically an HTTP 404 error for /HomeController/Create.
<p>@Html.ActionLink("Submit Request", "Create", "HomeController", new { title = "hello", description = "world" }, new { @class = "btn btn-primary"})</p>
<p>@Html.ActionLink("Submit Request", "Create", "HomeController", new { @class = "btn btn-primary"}, new { title = "hello", description = "world" })</p>
Here's the method in HomeController for the sake of completeness"
public ActionResult Create(string title, string description)
{
try
{
return RedirectToAction("Index");
}
catch (Exception ex)
{
return View("Index2");
}
}
Can anyone tell me what I'm missing or doing wrong?