因此,在我的 MVC Orchard 应用程序中,用户从 DD 中选择一个位置并从日期选择器中选择一个日期。然后搜索会查看数据库表并返回结果列表(如果有)。然后,用户可以使用“查看”按钮在屏幕上查看每条记录。这一切都很好,但是如果用户按下“后退”按钮,在查看记录后我会收到错误:
Webpage has expired
我在我的代码中查看了 GET 和 POST 的其他示例,我看不到任何差异。有谁知道为什么会发生这种情况,认为这与搜索有关,请参阅下面的代码
@model Project.ViewModels.SearchDeliveryRunsVM
@{
Script.Require("ShapesBase");
Layout.Title = T("Delivery Runs History").ToString();
Script.Require("jQuery");
Script.Require("jQueryUI");
Style.Require("jQueryUI_DatePicker");
}
@using (Html.BeginFormAntiForgeryPost())
{
<div>
<div style="display:inline-block">
<div class="editor-label">Delivery Run</div>
<div class="editor-label">@Html.DropDownList("DeliveryRunId", Model.DeliveryRunList)</div>
</div>
<div style="display:inline-block">
<div class="editor-label">@T("Date")</div>
<div class="editor-label">@Html.TextBoxFor(model => model.SelectedDate, new { @class = "jquery_datepicker", @Value = Model.SelectedDate.HasValue ? Model.SelectedDate.Value.ToString("dd/MM/yyyy") : string.Empty })</div>
</div>
<button style="display:inline-block" type="submit">@T("Search")</button>
</div>
if (Model.Orders != null && Model.Orders.Count() > 0)
{
<br />
<table class="items">
<colgroup>
<col id="Col10" />
<col id="Col11" />
</colgroup>
<tr>
<th>Order Id</th>
<th>Customer</th>
<th>Value</th>
<th>Payment</th>
<th>Signature</th>
<th></th>
</tr>
@foreach (Project.Models.OrderInfo results in Model.Orders)
{
<tr>
<td>@results.OrderRecordId</td>
<td>@results.QbCustName</td>
<td>@results.Value</td>
<td>@results.Payment</td>
<td>@Html.CheckBoxFor(x => results.Signature, new { disabled = "disabled" })</td>
<td>
<div>
<a href="@Url.Action("ViewOrder", "DeliveryRuns", new { id = results.OrderRecordId, custId = results.QbCustId })" title="@T("ViewOrder")">@T("ViewOrder")</a>
</div>
</td>
</tr>
}
</table>
}
else
{
if (!Model.IsInitialGet)
{
<p>No records exist</p>
}
}
}
@using (Script.Foot())
{
<script type="text/javascript" language="javascript">
$(function () {
var dates = $("#SelectedDate").datepicker({
dateFormat: 'dd/mm/yy'
}).val("@(Model.SelectedDate.HasValue ? Model.SelectedDate.Value.ToString("dd/MM/yyyy") : DateTime.Now.ToString("dd/MM/yyyy"))");
});
</script>
}
更新 我网站上的所有其他搜索功能都使用每个控制器的索引功能,然后在视图中使用类似的东西:
@using(Html.BeginForm("Index", "CustomerAdmin", FormMethod.Get)) {
<fieldset class="bulk-actions">
<label for="search">@T("Search:")</label>
@Html.TextBoxFor(m => m.SearchExpression)
<button type="submit">@T("Search")</button>
<a href="@Url.Action("Index")">@T("Clear")</a>
</fieldset>
}
使用 GET 来显示结果,而我的问题是我使用 GET 和 POST。也许?