Asp.net 应用程序中的服务器错误找不到资源

Asp.net 应用程序中的服务器错误找不到资源,asp.net,asp.net-mvc-3,Asp.net,Asp.net Mvc 3,我在一个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 t

我在一个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" }
))

这是我的房间打字机:

   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);
     }
   }
  }
使用系统;
使用System.Collections.Generic;
使用系统数据;
使用System.Data.Entity;
使用System.Data.Entity.Infrastructure;
使用System.Data.Object;
使用System.Linq;
使用System.Web;
使用System.Web.Mvc;
使用mvcapapplication4.模型;
命名空间mvcapapplication4.Controllers
{
公共类RoomTypeController:控制器
{
私有Hotelenties db=新Hotelenties();
//
//获取/RoomType/
公共视图结果索引(int start=0,int itemsPerPage=20,string orderBy=“RoomType\u ID”,bool desc=false)
{
ViewBag.Count=db.Room_Type.Count();
ViewBag.Start=开始;
ViewBag.ItemsPerPage=ItemsPerPage;
ViewBag.OrderBy=OrderBy;
ViewBag.Desc=Desc;
返回视图();
}
//
//获取:/RoomType/GridData/?start=0&itemsPerPage=20&orderBy=RoomType\u ID&desc=true
public ActionResult GridData(int start=0,int itemsPerPage=20,string orderBy=“RoomType\u ID”,bool desc=false)
{
Response.AppendHeader(“X-Total-Row-Count”,db.Room_Type.Count().ToString());
ObjectQuery room_type=(数据库作为IObjectContextAdapter)。ObjectContext.CreateObjectSet();
房间类型=房间类型.OrderBy(“it.+OrderBy+(desc?:”);
返回PartialView(房间类型.跳过(开始).Take(itemsPerPage));
}
//
//获取:/Default5/RowData/5
公共操作结果行数据(int id)
{
房间类型房间类型=db.Room\u Type.Find(id);
返回PartialView(“GridData”,新的Room_类型[]{Room_类型});
}
//
//获取:/RoomType/Create
公共操作结果创建()
{
返回部分视图(“编辑”);
}
//
//POST:/RoomType/Create
[HttpPost]
公共行动结果创建(房间类型房间类型)
{
if(ModelState.IsValid)
{
db.房间类型.添加(房间类型);
db.SaveChanges();
返回PartialView(“GridData”,新的Room_类型[]{Room_类型});
}
返回部分视图(“编辑”,房间类型);
}
//
//获取:/RoomType/Edit/5
公共操作结果编辑(int id)
{
房间类型房间类型=db.Room\u Type.Find(id);
返回部分视图(房间类型);
}
//
//POST:/RoomType/Edit/5
[HttpPost]
公共行动结果编辑(房间类型房间类型)
{
if(ModelState.IsValid)
{
db.Entry(房间类型).State=EntityState.Modified;
db.SaveChanges();
返回PartialView(“GridData”,新的Room_类型[]{Room_类型});
}
返回部分视图(房间类型);
}
//
//POST:/RoomType/Delete/5
[HttpPost]
公共无效删除(int-id)
{
房间类型房间类型=db.Room\u Type.Find(id);
db.房间类型。移除(房间类型);
db.SaveChanges();
}
受保护的覆盖无效处置(布尔处置)
{
db.Dispose();
基地。处置(处置);
}
}
}

确保您的控制器类被称为
RoomTypeController
(而不是
RoomType
,也不是
RoomController
),并且它包含
索引
操作:

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

确保您的控制器类被称为
RoomTypeController
(而不是
RoomType
,也不是
RoomController
),并且它包含
索引
操作:

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

你需要提供更多的信息。这是从Visual Studio web服务器运行应用程序还是在IIS中运行应用程序?如果是IIS,是6还是7?当控制器在“家”时,它是否工作?此外,您不在“web配置”中指定路由,而是在Global.asaxYes中指定,当我的控制器在房间中工作时,它会工作,但当我尝试转到时,我会收到错误,您需要提供更多信息。这是从Visual Studio web服务器运行应用程序还是在IIS中运行应用程序?如果是IIS,是6还是7?当控制器在“家”时,它是否工作?另外,您没有在“web配置”中指定路由,而是在Global.asaxYes中指定,当我的控制器在房间中工作时,它会工作,但当我尝试转到时,我得到一个错误,那里有一个输入错误,应该是return View();别担心,你已经帮了我好几次了。这是我至少能做的;)在我的RoomType控制器中,我没有ActionREsult索引,但我有ViewResult索引。这可能是问题所在吗?我把RoomType控制器中的代码放在问题中了。不,这不是问题所在,尽管始终使用对象层次结构中可能最高的类(在本例中为ActionREsult)是一种很好的做法。您的
registerOutes
方法中是否有其他一些未显示的路由定义?这可能也是一个愚蠢的问题,但在修改路线定义后,你是否重新编译了项目?哦,不,那些路线完全不兼容。它们都遵循相同的模式
{controller}/{action}/{id}
。那是不可能的。定义路由是因为它具有特定的url模式。您应该保留在创建应用程序时向导生成的默认路由,而不是创建3个相同的路由。它可以同时使用
/Room
/RoomType
URL;别担心,你已经帮了我好几次了。这是我至少能做的;)在我的RoomType控制器中,我没有ActionREsult索引,但我有ViewResult索引。这可能是问题所在吗?我把RoomType控制器中的代码放在问题中了。不,这不是问题所在,尽管始终使用对象层次结构中可能最高的类(在本例中为ActionREsult)是一种很好的做法。还有别的吗