RedirectToAction方法不起作用,过去4小时无法解决。以下是User controler的代码:
[HttpPost, ValidateAntiForgeryToken]
public ActionResult Register(UsersNew form)
{
var user= new User();
UserDB db = new UserDB();
db.addUser(form.Username, form.Password, form.SchoolName, form.Country, form.City);
return RedirectToAction("Home");
}
它表示没有这样的路由注册,虽然它将用户添加到数据库,因此只有重定向不起作用。这是我的routeConfig文件:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("Home", "", new { controller = "First", action = "FirstView" });
routes.MapRoute("Register", "register", new { Controller = "Users", action = "Register" });
routes.MapRoute("About", "about", new { Controller = "About", action = "About" });
}