错误如下:
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: /Home/Offers
我使用Visual Studio 2013在MVC中编写Web应用程序,除了HomeController.cs文件之外,我没有修改任何其他内容。
HomeController.cs:
namespace MvcApplication1.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Pid = "page1";
return View();
}
public ActionResult Contact()
{
ViewBag.Pid = "page6";
return View();
}
public ActionResult Book()
{
ViewBag.Pid = "page3";
return View();
}
public ActionResult Book2()
{
ViewBag.Pid = "page3";
return View();
}
public ActionResult Offers()
{
ViewBag.Pid = "page2";
return View();
}
public ActionResult Safety()
{
ViewBag.Pid = "page5";
return View();
}
public ActionResult Services()
{
ViewBag.Pid = "page4";
return View();
}
}
}
我的观看文件夹:
Views
Account
Home
Book.cshtml
Book2.cshtml
Contract.cshtml
Index.cshtml
Offers.cshtml
Safety.cshtml
Services.cshtml
Shared
模板附带的前三个cshtml文件除外,它是Index,Contract,&关于(更改为Book),我添加的每个其他文件都不起作用。
请帮助~~~~
*编辑: RouteConfig.cs:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}