私はASp.netmvc3プロジェクトで働いていますが、このエラーが発生し続け、問題を解決するためのヘルプを見つけることができます
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: /RoomType
しかし、私はRoomTypeコントローラーを持っており、Global.asaxには次のものがあります。
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
null, // we don't need to specify a name
"Page{page}",
new { Controller = "Room", action = "List" }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Room", action = "List", id = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
null, // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Room", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
routes.MapRoute(
null, // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "RoomType", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
これが私のRoomTypeControllerです:
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Objects;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcApplication4.Models;
namespace MvcApplication4.Controllers
{
public class RoomTypeController : Controller
{
private hotelEntities db = new hotelEntities();
//
// GET: /RoomType/
public ViewResult Index(int start = 0, int itemsPerPage = 20, string orderBy = "RoomType_ID", bool desc = false)
{
ViewBag.Count = db.Room_Type.Count();
ViewBag.Start = start;
ViewBag.ItemsPerPage = itemsPerPage;
ViewBag.OrderBy = orderBy;
ViewBag.Desc = desc;
return View();
}
//
// GET: /RoomType/GridData/?start=0&itemsPerPage=20&orderBy=RoomType_ID&desc=true
public ActionResult GridData(int start = 0, int itemsPerPage = 20, string orderBy = "RoomType_ID", bool desc = false)
{
Response.AppendHeader("X-Total-Row-Count", db.Room_Type.Count().ToString());
ObjectQuery<Room_Type> room_type = (db as IObjectContextAdapter).ObjectContext.CreateObjectSet<Room_Type>();
room_type = room_type.OrderBy("it." + orderBy + (desc ? " desc" : ""));
return PartialView(room_type.Skip(start).Take(itemsPerPage));
}
//
// GET: /Default5/RowData/5
public ActionResult RowData(int id)
{
Room_Type room_type = db.Room_Type.Find(id);
return PartialView("GridData", new Room_Type[] { room_type });
}
//
// GET: /RoomType/Create
public ActionResult Create()
{
return PartialView("Edit");
}
//
// POST: /RoomType/Create
[HttpPost]
public ActionResult Create(Room_Type room_type)
{
if (ModelState.IsValid)
{
db.Room_Type.Add(room_type);
db.SaveChanges();
return PartialView("GridData", new Room_Type[] { room_type });
}
return PartialView("Edit", room_type);
}
//
// GET: /RoomType/Edit/5
public ActionResult Edit(int id)
{
Room_Type room_type = db.Room_Type.Find(id);
return PartialView(room_type);
}
//
// POST: /RoomType/Edit/5
[HttpPost]
public ActionResult Edit(Room_Type room_type)
{
if (ModelState.IsValid)
{
db.Entry(room_type).State = EntityState.Modified;
db.SaveChanges();
return PartialView("GridData", new Room_Type[] { room_type });
}
return PartialView(room_type);
}
//
// POST: /RoomType/Delete/5
[HttpPost]
public void Delete(int id)
{
Room_Type room_type = db.Room_Type.Find(id);
db.Room_Type.Remove(room_type);
db.SaveChanges();
}
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
}
}