我是MVC框架的新手;我正在努力学习。
我尝试从登录主页重定向
[HttpPost]
public ActionResult Login(Register model)
{
StudentDBHandle db = new StudentDBHandle();
DataTable dst = db.Login(model);
if (dst.Rows.Count==1)
return RedirectToAction("Index","Student");
else
{
ViewBag.Message = "Login Failed";
return View();
}
}
它说"路由表中没有路由匹配提供的值。"
所以我在routeconfig文件中添加了路由
public static void RegisterRoutes(RouteCollection routes
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Login",
url: "{controller}",
defaults: new { controller = "Register", action = "Login", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "HomePage",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Student", action = "Index", id = UrlParameter.Optional }
);
}
登录成功后,会重定向到同一个登录页面
我已经改变了订单,但它没有用。