2012-04-23 4 views
0

私はこのエラーを得続けると問題サーバエラーは、リソースが

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 

を解決するために任意のヘルプを見つけることができますASp.netのMVC 3プロジェクトと で働いて見つけることができません。しかし、私は持っていますルームタイプのコントローラと私の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); 
    } 
    } 
    } 
+2

詳細をお知らせください。これは、Visual Studio WebサーバーまたはIISからアプリを実行するときですか? IISの場合は、6または7ですか?コントローラーが「ホーム」のときは以前は機能しましたか?また、 "web config"のルートを指定しないでください.Global.asaxで行います。 –

+0

はい、私のコントローラーがRoom http:// localhost:51757/roomで動作していますが、httpに行くとき:// localhost:51757/RoomType私はエラーを受け取ります – jonny

答えて

3

があなたのコントローラクラスがRoomTypeController(とないRoomType、およびないRoomController)と呼ばれていることを確認し、それがIndexアクションが含まれていること:

public class RoomTypeController : Controller 
{ 
    public ActionResult Index() 
    { 
     return View(); 
    } 
} 
+0

そこにはタイプミスがあります。 – Dante

+0

良いキャッチ、ありがとう。 –

+1

心配しなくても、あなたはすでに何度も私を助けてくれました。 ) – Dante

関連する問題