That's because you input tag has the value as all
. In this case, it's a good pratice to bind the right type, for sample:
public ActionResult Post(bool all)
{
//here you will get the all boolean value, if check or not as boolean
}
Or, better than this, you could create a ViewModel and bind it, for sample:
Add a class wih the fields you want to use on the Models folder.
public class MyViewModel
{
public string Name { get; set; }
public bool All { get; set; }
}
After it, in your View, you just type the View and create the controls using the Html helpers, for sample:
@model Models.MyViewModel
@using (Html.BeginForm("Post", "Home", FormMethod.Post))
{
@Html.TextBoxFor(model => model.Name)
@Html.CheckBoxFor(model => model.All)
<input type="submit" value="Send" />
}
Obs: it's just a sample
And in your controller, you just get a instance of this model, and let asp.net mvc bind it for you as the object:
public ActionResult Post(MyViewModel model)
{
// here you have the model.All as boolean value
}
It's a good pratice to do, because ViewModels represents the fields you need on the View and transfer it between contexts (controllers, views, services, apis, etc..).