0

I fully expect the solution to be something simple like a small detail i forgot, but for the life of me i cannot figure out what i am doing wrong

Action Link :

 @Html.ActionLink(
        linkText: "Confirm",
        actionName: "AdminVitalBitsCD",
         controllerName: "Configuration",
         routeValues: new
         {
              Title = Model.VitalBit.Title,
              Message = Model.VitalBit.Message,
              IsActive = Model.VitalBit.IsActive,
              IsPriority = Model.VitalBit.IsPriority,
              bitName = Model.VitalBit.BitType.Name,
              Created = Model.VitalBit.Created

         },
              htmlAttributes: null
       )

Controller :

[HttpGet]
public ActionResult AdminVitalBitsCD(string Title, string Message, bool IsActive, bool IsPriority, string bitName, DateTime Created)
{ 
    return View("~/Views/Configuration/AdminVitalBits.cshtml", viewModel);
}

When i click on my link the break point is hit in my controller and no error is thrown. The problem is all of the parameters are either null or their default value (Created = {1/1/0001 12:00:00 AM}). Am i forgetting something simple?

If anything else is need let me know. Thanks in advance

8
  • 1
    what's the link that ActionLink is creating? Commented Apr 23, 2018 at 18:07
  • copy and pasted from the source it is :<a href="/Configuration/AdminVitalBitsCD?IsActive=False&amp;IsPriority=False&amp;Created=01%2F01%2F0001%2000%3A00%3A00">Confirm</a> Commented Apr 23, 2018 at 18:18
  • Try prefixing the property with @ with every property of routesValues. Like @Title e.t.c. Commented Apr 23, 2018 at 18:18
  • Nope @ didn't work Commented Apr 23, 2018 at 18:19
  • Try adding [FromUri] before each input parameters. see if it works. Commented Apr 23, 2018 at 18:22

1 Answer 1

1

A much simpler way and open for extension is to send a JSON object back to the controller. You would need to create an equivalent C# POCO class and use it in the controller but it is pretty simple.

[HttpGet]
public ActionResult AdminVitalBitsCD(PocoDataClass data)
{ 
    return View("~/Views/Configuration/AdminVitalBits.cshtml", viewModel);
}

Add this class to your C# project.

public class PocoDataClass 
{
   public string Title { get; set; }
   public string Message { get; set; }
   ...
}
Sign up to request clarification or add additional context in comments.

1 Comment

Took a tutorial but i got it working now doing this. Thanks for the help

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.