Witam ,gdy chce usunac obrazek wyskakuje mi taki błąd :System.ArgumentNullException: 'Value cannot be null.
Parameter name: entity'
MemyController zawiera metode :
[HttpPost]
public ActionResult Delete(int idd)
{
Memy pom = db.Memy.Find(idd);
db.Memy.Remove(pom);
db.SaveChanges();
return RedirectToAction("Index");
}
views->memy->index
<style>
body {
background-color: grey;
}
.foto {
height: 400px;
width: 400px;
margin-left: auto;
margin-right: auto;
}
.table {
text-align: center;
font-size: 40px;
font-family: Arial;
}
.opis {
font-size: 50px;
}
</style>
<br>
<table class="table">
@foreach (var item in Model)
{
<h1>@item.Title</h1>
<input type="button" value="Delete" class="btn btn-danger" />
<a>
<img class="foto" src="@item.coverImg" />
<br />
<br />
</a>
<p class="opis">@item.Description</p>
<td>@item.Description</td>
<td>@item.Category</td>
<td>@item.releaseDate</td>
<td>@item.modifyDate</td>
<td>@item.Id_mema</td>
<td>@item.Like</td>
<td>@item.Dislike</td>
@if (SignInManager.IsSignedIn(User))
{
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.Id_mema }, new { id = item.Id_mema, @class = "btn btn-primary", @style = "margin-bottom: 20px;" })
</td>
<td>
<input type="button" value="Delete" class="btn btn-danger" />
</td>
@using (Html.BeginForm("delete", "memy", FormMethod.Post, new { name = "frmMovie", id = "frmMovie" }))
{
<input type="hidden" name="id" />
}
}
}
</table>
@section Scripts
{
<script>
$(".btn-danger").click(function () {
if (!confirm('Do you really want to delete this mem?')) {
return false;
}
var id = $(this).closest("tr").find(".item-id").text();
document.frmMovie.id.value = id;
document.getElementById("frmMovie").submit();
});
</script>
}
przeglądałem
https://stackoverflow.com/questions/34863167/asp-net-mvc-why-is-my-view-passing-null-models-back-to-my-controller
ale jakoś nie moge zrozumieć co jest źle..
nie rozumiem jaka jest przyczyna tego błędu...