사용자가 파일을 업로드 한 다음 의사가 검토합니다. 의사는 자신의 발언을 적어 둔 파일을 업로드 한 다음 사용자가 파일을 읽을 수 있습니다. 적어도, 그들은 할 수 있어야합니다. 의사가 파일을 업로드하면 사용자의 폴더 안에 새로운 디렉토리가 만들어지고 해당 항목이 해당 폴더에 업로드됩니다.C#/ASP.NET ActionLink/Functions/Wrong Linking
이제 버그. 세부 정보 페이지에는 의사 노트를 읽을 수 있도록 다운로드 할 파일 링크가 있음을 알 수 있습니다. 하지만 링크를 클릭하면 링크가 404로 돌아옵니다. 파일을 검토 폴더에서 제거하고 기본 사용자 디렉토리에 추가하면 링크가 작동합니다. 분명히 링크가 정확한 위치를 가리키고 있지는 않지만 .NET 또는 C#을 알지 못하기 때문에 이것은 매우 성가심이있는 것으로 입증되었습니다.
<table>
<tr>
<th colspan="4" class="display-label">Uploaded Documents</th>
</tr>
<tr>
<th>FileName</th>
<th>Download Files</th>
</tr>
@foreach (var file in ((IEnumerable<MyCombinedQueryModel>)ViewBag.Files))
{<tr>
<td>
@Html.ActionLink("Download", "Download", new { id = Model.PatientsId, name = file.FileName })
</td>
<td>
@file.FileName
</td>
</tr>
}<tr>
<th colspan="4" class="display-label">Download reviewer suggestion document</th></tr>
<tr>
<th>FileName</th>
<th>Download Files</th>
</tr>
@if(Model.reviewed)
{
foreach (var file in ((IEnumerable<MyCombinedQueryModel>) ViewBag.Path))
{
<tr>
<td>
@Html.ActionLink("Download", "Download", new {id = Model.PatientsId, name = file.FileName})
</td>
<td>
@file.FileName
</td>
</tr>
}
}
</table>
그리고 DoctorsController.cs
우리의 데이타베이스는 이제//Download files string names
public ActionResult Download(int? id, string name)
{
string fileName = name;
var uploads = (from u in _db.Patients
where u.PatientsId == id
select u.FilesUrl).FirstOrDefault();
if (uploads != null)
{
string folder = Path.GetFullPath(uploads);
//HttpContext.Response.AddHeader("content-dispostion", "attachment; filename=" + fileName);
return File(new FileStream(folder +"/" + fileName, FileMode.Open), "content-dispostion", fileName);
}
throw new ArgumentException("Invalid file name of file not exist");
}
우리는 두 개의 필드, FilesUrl을 가지고에서 부분 : 여기
는 Details.cshtml 페이지에서 원래 코드의 일부입니다 PathUrl. PathUrl은 검토 폴더에 검토 된 파일의 URL을 보유합니다. 필자는 필자가 맞다면 FileUrl에만 링크 된 동일한 기능 (다운로드)을 호출하고 있다는 것을 알았습니다. 검토 된 부분의 actionLink를 세부 정보 페이지의 "DownloadR"로 변경하고 다운로드 기능을 복사 및 붙여 넣기 (DownloadR로 이름을 변경하고 PathUrl을 찾기 위해 변경)했지만 여전히 올바르게 작동하지 않았습니다.
문제가 있거나 해결 방법에 대한 조언이있는 사람이 있습니까? 당신의 시간 동안 미리 감사드립니다!
감사합니다. 나는 reviewDirectory에 넣은 것에 대해 다소 혼란 스럽다. 실제로 경로를 작성합니까? C :/inetpub/wwwroot 등? 미안 미안하지만 이것은 초보자가 아닌 질문이지만 프로그래머가 아닙니다. – user1686221