Witam.
Pół dania przesiedziałem nad rozwiązaniem problemu.
Błąd:
The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[Allepliki.Models.pliki]', but this dictionary requires a model item of type 'Allepliki.Models.uzytkownicy'.
public ActionResult YourFiles()
{
string Login = (string)Session["LoginUserLogin"];
var pliki = db.pliki.Where(p => p.login == Login);
return View(pliki.ToList());
}
@model IEnumerable<Allepliki.Models.pliki>
@{
ViewBag.Title = "Index";
}
@if (Session["LoginUserID"] != null)
{
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.autor)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.autor)
</td>
</tr>
}
</table>
}
Badając kod debugerem zauważyłem ze jak w pliku logowanie.chtml nie ma.
@model Allepliki.Models.uzytkownicy
@using(Html.BeginForm("Index", "Home", FormMethod.Post))
{
@Html.AntiForgeryToken();
@Html.ValidationSummary(true);
@Html.TextBoxFor(a => a.login)
@Html.TextBoxFor(a => a.haslo)
<input type="submit" value="Login" />
}
to wszytsko działa poprawnie.