I am trying to pass a hidden value from View to Controller in ASP.NET Core.
@using (Html.BeginForm("PostTest", "Test", FormMethod.Post)
{
@Html.HiddenFor(model => model.id, new { @Value = "123456789" })
}
In my controller, I am receiving it as a model
public ActionResult TestId(ObjTest objTest)
{
string result = objTest.id;
Console.WriteLine(result)
}
This is my model:
public class ObjTest
{
public string id { get; set; }
}
However, I am unable to retrieve the value "123456789".

TestIdaction fromView? Please share that code as well. If you are usingForm&Submitbutton then make sure your@Html.HiddenForline is written insideFormHtml.BeginFormfor the form.