This is a translation of the question Why does query string parameter get included twice asp.net boolean
I have a page with the following code:
<div class="editor-field"> @Html.CheckBoxFor(model => model.IncludeArchive) @Html.ValidationMessageFor(model => model.IncludeArchive) </div> Model class:
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 I open the page and then select the IncludeArchive checkbox, the address line changes to the following:
http://localhost:64005/test/?FirstName=&LastName=&TestNumber=&IncludeArchive=true&IncludeArchive=false Explain why the IncludeArchive variable is included twice in the url?