Em tạo 1 Controller và 1 Index trong MVC. Cái đầu tiên này thì chạy bình thường
Nhưng đến khi tạo Controller và Index thứ 2 thì lại báo lỗi thiếu file " The resource cannot be found "
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /NhaMoiGioi/Index
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.9037.0
( 2 src code của 2 Controller y chang nhau ). Mong mọi người hỗ trợ
Controller 1 và Index 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.Entity;
using QuanLyNhaAnWeb.Models;
using System.IO;
namespace QuanLyNhaAnWeb.Controllers
{
public class TESTController : Controller
{
public ActionResult Index()
{
return View();
}
}
}
@model IEnumerable<TTCK.Models.KHACHHANG>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.MAKH)
</th>
<th>
@Html.DisplayNameFor(model => model.TENKH)
</th>
<th>
@Html.DisplayNameFor(model => model.DIACHI)
</th>
<th>
@Html.DisplayNameFor(model => model.DIENTHOAI)
</th>
<th>
@Html.DisplayNameFor(model => model.THUNHAP)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.MAKH)
</td>
<td>
@Html.DisplayFor(modelItem => item.TENKH)
</td>
<td>
@Html.DisplayFor(modelItem => item.DIACHI)
</td>
<td>
@Html.DisplayFor(modelItem => item.DIENTHOAI)
</td>
<td>
@Html.DisplayFor(modelItem => item.THUNHAP)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.MAKH })
@Html.ActionLink("Details", "Details", new { id=item.MAKH })
@Html.ActionLink("Delete", "Delete", new { id=item.MAKH })
</td>
</tr>
}
</table>
Controller 2 và Index 2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.Entity;
using TTCK.Models;
namespace Thitruongchungkhoan.Controllers
{
public class NhaMoiGioiController : Controller
{
TTCKEntities db = new TTCKEntities();
public ActionResult Index()
{
var da = from NMG in db.NHAMOIGIOIs select NMG;
return View(da);
}
@model IEnumerable<TTCK.Models.NHAMOIGIOI>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table class="table">
<tr>
<th>
@Html.DisplayNameFor(model => model.TENNHAMOIGIOI)
</th>
<th>
@Html.DisplayNameFor(model => model.DIACHI)
</th>
<th>
@Html.DisplayNameFor(model => model.DIENTHOAI)
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.TENNHAMOIGIOI)
</td>
<td>
@Html.DisplayFor(modelItem => item.DIACHI)
</td>
<td>
@Html.DisplayFor(modelItem => item.DIENTHOAI)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.MANHAMOIGIOI }) |
@Html.ActionLink("Details", "Details", new { id=item.MANHAMOIGIOI }) |
@Html.ActionLink("Delete", "Delete", new { id=item.MANHAMOIGIOI })
</td>
</tr>
}
</table>