Edited: To remove superfluous code that may cloud the issue.
The model that is used is as follows:
public class StockProcessSearchModel : BaseSearchModel
{
public bool IsOutOfStock { get; set; }
}
public class BaseSearchModel
{
public bool IsExpected { get; set; }
public bool IsInStock { get; set; }
}
Here is the only defined route:
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute(
name: "Home",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Authorisations", action = "Index", id = UrlParameter.Optional });
}
The input in the view is nothing special / just dumb html.
<input type="submit" value="Arrivals" name="DisplayArrivals" />
Now I've set the scene, the issue is a bit odd... it is giving the following querystring when I click the DisplayArrivals input, i.e. it duplicates the parameter descriptors but not the value, i.e. true then false:
(I should add that the parameters should be: IsExpected=true&IsInStock=true&IsOutOfStock=false)
Running Fiddler4 it tells me that the requested URL (immediately once the input is clicked) is:
and a break-point in the DisplayArrivals code proves that the 'duplication' is occurring before my own code does anything?!?! Which leads me to believe it must be a routing / mapping / model binding issue.
I would like to know why it is duplicating these querystring elements and more importantly how to prevent it.
EDIT: As requested here is how I generate the inputs for the IsInStock and IsExpected and IsOutOfStock:
@if (!Model.IsInStock && !Model.IsExpected && !Model.IsOutOfStock)
{
@Html.CheckBox("IsExpected", true)
@Html.CheckBox("IsInStock", true)
}
else
{
@Html.CheckBoxFor(m => m.IsExpected)
@Html.CheckBoxFor(m => m.IsInStock)
}
@Html.CheckBoxFor(m => m.IsOutOfStock)