I've got my Index page with the following code:
<div class="editor-field">
@Html.CheckBoxFor(model => model.IncludeArchive)
@Html.ValidationMessageFor(model => model.IncludeArchive)
</div>
my model is:
public class SearchModel
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string TestNumber { get; set; }
public bool IncludeArchive { get; set; }
}
[Authorize]
public ActionResult Index(SearchModel search)
{
var test= db.Test.AsQueryable();
if (Request.QueryString.Count > 0) {
if (!search.IncludeArchive) test = test.Where(x => x.Status == "Active");
} else {
test= test.Where(x => x.Status == "Active");
}
ViewBag.testList = test.ToList();
When browsing to the page then choosing the IncludeArchive checkbox to enable it to true, the query string turns to
http://localhost:64005/test/?FirstName=&LastName=&TestNumber=&IncludeArchive=true&IncludeArchive=false
Why does it include the variable IncludeArchive in the query string twice?
Thanks