我有一个名为UserController的控制器,并且只调用了Index操作,添加了另外一个操作,例如' home action '没有被调用,并且调用了actionresult/string或者返回视图
我收到了这个错误
在谷歌浏览器上运行时
{"消息":"找不到与请求URI匹配的HTTP资源URI /user/home'.","MessageDetail":"找不到与名为'home'的控制器匹配的类型."}
并在Mozilla Firefox上运行
哎呦!找不到该页面.试着再给它一次机会.
这是我的整个控制器代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace Mvc4Application1.Controllers
{
public class UserController : Controller
{
//
// GET: /User/
public ActionResult Index()
{
return View();
}
public ActionResult AddPlace()
{
return View();
}
public ActionResult UpdatePlace()
{
return View();
}
public ActionResult DeletePlace()
{
return View();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是RouteConfig.cs文件
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new
{ controller = "Home", action = …
Run Code Online (Sandbox Code Playgroud)