您的代码将生成正确的表单操作url,其中包含
showDeleted
参数
action="/Inventory/Page?showDeleted=False"
但既然你在使用
作为表单提交方法,当表单提交时,浏览器将从表单中读取输入元素值,并构建查询字符串并将其附加到表单操作url。这将覆盖您在那里已有的查询字符串。
如果你想用querystring发送这个
GET
作为form方法,表单中应该有一个同名的输入元素
@using (Html.BeginForm("Page", "Inventory", FormMethod.Get))
{
@Html.EditorFor(m => m.Search.SearchTerm,
new { htmlAttributes = new { @class = "form-control" } })
<input type="hidden" name="showDeleted" value="false" />
<button type="submit" class="btn btn-primary filter">Filter Results</button>
}