2017-12-28 16 views
0

내 페이지에서 클라이언트의 이름, 성, 기록 등을 기반으로 ActionLinks를 만듭니다. 클라이언트 기록이 너무 길면 414 오류가 발생합니다. .HTTP 오류 414. ActionLink를 사용하여 요청 URL이 너무 깁니다.

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은

그리고 this (때문에 역사) 약 18,000 자입니다 URL은 어떻게이 문제를 해결하기 위해 ActionLink

모든 단서의 결과인가?

+0

성은 18000 자입니까? – Jonny

+0

아니요, 클라이언트의 기록은 – dqm

+2

입니다. 오류 메시지는 분명합니다. URL은 너무 길어서는 안됩니다. 그러한 URL을 생성하는 이유는 무엇입니까? –

답변

2

pastebin url을 바탕으로 경로가 클라이언트 개체의 필드 중 하나를 ID (894 값)로 사용하고있는 것처럼 보입니다. 일반적인 조언은 ID를 다음 페이지로 보내고 데이터베이스에서 기록을 다시로드하는 것입니다. 그렇게하면 당신은 오래 가지 못하고 민감하게 될 수있는 많은 데이터를 넘겨야 만합니다.

나는 레코드의 열쇠 인 필드를 식별하고 전달할 것입니다. 필드가 ID라고하면 다음과 같이됩니다.

@Html.ActionLink(client.LastName, "DisplayClientDo", "DisplayClient", new { client.ID }, null) 
+0

이것은 다소 효과가 있습니다. 다음 페이지로 이동합니다. 많은 감사합니다. 이제 다음 페이지에서 내 모든 텍스트 상자는 비어 있습니다. < "플로트 : 왼쪽"DIV 스타일 => @using (Html.BeginForm ("SaveEditsAndReturnToMain", "DisplayClient"FormMethod.Post)) { : 그들은의 형태에 @ Html.TextBoxFor (X => x.FirstName) @ Html.TextBoxFor (x => x.LastName) @ Html.TextBoxFor (x => x.Dob) – dqm

+2

데이터가 더 이상 URL에 없기 때문에 다른 곳에서로드해야합니다. 일반적으로 컨트롤러에서 ID를 경로 데이터에서 가져 와서 레코드에 대한 데이터베이스를 쿼리하고 뷰 모델을 채우고 템플릿에 대한 뷰로 전달합니다. –

+0

오른쪽. 그래서 나는 내 컨트롤러로 돌아가서 레코드를 검색하기 위해 db를 쿼리해야 할 것인가? – dqm