.NET에서 개발하기 시작했으며 몇 가지 질문이 있습니다.다른 컨트롤러의 뷰 표시 MVC5
저는 Azure에 이미지를 업로드하는보기를 만들었습니다. 이보기는 문서라는 컨트롤러에 포함되어 있습니다.
내가 원하는 것은 다른 컨트롤러보기에서이보기를 표시하는 것입니다. 보기는 완벽하게 혼자 작동하지만 참조 할 때 오류가 발생하여 해결 방법을 아직 모릅니다.
이 뷰 "Upload.cshtml"
@{
ViewBag.Title = "Upload";
}
<p>
@using (Html.BeginForm("Upload", "Documento", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<input type="file" id="fileToUpload" name="image" />
<input type="submit" id="btnSubmit" value="Upload" />
}
</p>
<ul style="list-style-type: none; padding: 0;">
@foreach (var item in Model)
{
<li>
<img src="@item" alt="images" width="100" height="100" />
<a id="@item" href="#" onclick="deleteImage('@item');">Delete</a>
</li>
}
</ul>
<script type="text/jscript">
//get file size
function deleteImage(item) {
try {
var url = "/Documento/DeleteImage";
$.post(url, { Name: item }, function (data) {
window.location.href = "/Documento/Upload";
alert(data);
});
}
catch (e) {
alert("Error is :" + e);
}
}
</script>
입니다 그리고 이것은 내가 다른 컨트롤러 인덱스보기에서보기를 호출 할 방법은 다음과 같습니다
@RenderPage("~/Views/Documento/Upload.cshtml");
@RenderBody();
그리고 내가 오류가 있기 때문이다 "@foreach (모델의 var 항목)"문장 중 하나입니다.
어떻게해야합니까?
죄송합니다 모두, 나는 밖으로 있었어요. 내가 URL을 가져 와서 Document.Url에 추가하고 싶다면 Upload 메서드를 호출하면 새 문서를 만들 수 있습니다. 일단 내가 성취하면 나는 당신이 말하는 것을 할 수있을 것이라고 생각합니다. – dak