C# MVC4 Partial View with other ActionResult in Controller
asp.net-mvc, c#-4.0, model-view-controller, partial-views, razor
Solution
Change
@{Html.Action("_PartialView", "DashboardNB2");}
to
@Html.Action("_PartialView", "DashboardNB2")
Problem
i have a problem. I have my Controller "DashboardNB2Controller", my View "index.cshtml" and i want to integrate a partial view called "_PartialView.cshtml" in my "index.cshtml". Both Views are in the same folder. In my controller, i have the "ActionResult _PartialView" for a databaseoperation in my partial view. But if I integrate my partial view in my index view, the action result "_PartialView" didn't work. I get no results. The query for my database is correct. I checked this. Here are my codes My Controller with the ActionResult for the Partial View ``` public ActionResult _PartialView() { var lastMessages= (from t in db.view_tbl_message orderby t.Date descending select t).Take(10); ViewModelDashboard model = new ViewModelDashboard(); model.view_tbl_message = lastMessages.ToList(); return PartialView("_PartialView", model); } ``` My index.cshtml ``` @model AisWebController.Areas.Statistics.Models.ViewModelDashboard @{ ViewBag.Title = "Index"; Layout = "~/Views/Shared/_Layout.cshtml"; } <br /> @{Html.Action("_PartialView", "DashboardNB2");} <br /> ``` And my _PartialView.cshtml ``` @model WebApplication.Areas.Stats.Models.ViewModelDashboard <table class="table table-bordered"> <tr> <th> Date </th> <th> User </th> <th> Message </th> </tr> @foreach (var item in Model.view_tbl_message) { <tr> <td> @Html.DisplayFor(modelItem => item.Date </td> <td> @Html.DisplayFor(modelItem => item.User) </td> <td> @Html.DisplayFor(modelItem => item.Message) </td> </tr> } </table> ``` If someone can help - that would be aweseome!