【发布时间】:2017-12-28 14:55:35
【问题描述】:
在我的页面中,我正在根据客户的名字、姓氏、历史等创建 ActionLink。 当客户端历史太长时,我会收到 414 错误。
public class SearchViewModel
{
public char[] Alphabet => "ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩ".ToCharArray();
public char ClientSearchString { get; set; }
public List<ClientViewModel> ClientsList { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Dob { get; set; }
public bool Edit { get; set; }
public string Address { get; set; }
public string Job { get; set; }
public string Mobile { get; set; }
public string LastVisit { get; set; }
public string Record { get; set; }
public string Pit { get; set; }
public string Er { get; set; }
public string Ter { get; set; }
public string History { get; set; }
public int Id { get; set; }
public bool OldRecord { get; set; }
}
@foreach (var client in clientList)
{
if (!string.IsNullOrEmpty(client.LastName))
{
<tbody id="rounded-corner">
<tr id="rounded-corner">
<td>
@Html.ActionLink(client.LastName, "DisplayClientDo", "DisplayClient", client, null)
</td>
<td>
@Html.DisplayFor(x => client.FirstName)
</td>
<td>
@Html.DisplayFor(x => client.Dob)
</td>
<td>
@Html.DisplayFor(x => client.Address)
</td>
<td>
@Html.DisplayFor(x => client.Telephone)
</td>
<td>
@Html.DisplayFor(x => client.LastVisit)
</td>
</tr>
</tbody>
}
public ActionResult DisplayClientDo(ClientViewModel model)
{
return View("DisplayClient", model);
}
我认为该页面在浏览器中失败。 URL 大约 18000 个字符长(由于历史原因)
this 是 ActionLink 产生的 url
任何线索如何解决这个问题?
【问题讨论】:
-
姓氏是否有 18 000 个字符?
-
不,客户的历史是
-
错误信息很清楚。 URL 不应该那么长。为什么要生成这样的 URL?
-
因为我将所有这些信息从 ActionLink 发布到另一个视图,该视图将每个元素呈现到文本框进行编辑
-
我现在注意到了你的 pastebin。您正在将整个客户端对象序列化到请求中。为什么?标准方法是仅通过 clientID 或类似名称引用客户端。
标签: c# asp.net-mvc