I'm new to MVC Framework; I'm trying to learn.
I'm trying to Redirect from Login to Home Page
[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();
}
}
it says "No route in the route table matches the supplied values."
So I Added Route in routeconfig file
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 }
);
}
When the login succeeds, it redirects to the same Login page
I have changed the order, but it's not working.