I have converted an ASP.net mvc 2.0 web application to ASP.net MVC 4.6. it seems the same RedirectToAction code doesn't work in the new EF 4.6.
Basically, in the LogOn
method of the AccountController
, I have code:
return RedirectToAction("Index","Calendar");
to call the Index
method of CalendarController
. And within the CalendarController:Controller {
, there is a Index()
method such as:
[AcceptVerbs(HttpVerbs.Get]
public ActionResult Index() {..
These codes work in ASP.net MVC 2.0, the method Index()
within RedirectToAction
is called properly. But it is not working in asp.net MVC R4.6, in debug, RedirectToAction()
just called the default constructor (public CalendarController()
) of CalendarController
, it doesn't execute the method Index()
of CalendarController
. Instead, after it executes the default constructor of CalendarController
, it then executes Application_BeginRequest()
method of Global.asax.cs
, then it executes the Index()
method of HomeController
. The Index()
method of CalendarController
is ignored.
From what I can see there is no Ajax post in the razor view, and the routing table is as below:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"ReferenceTables", // Route name
"ReferenceTables/{action}/{tablename}/{id}", // URL with parameters
new { controller = "ReferenceTables", action = "Index", id = @"" } // Parameter defaults
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
Does anybody know what caused the RedirectToAction
is not working in my case?
Thanks a lot for any help,
By the way, there is no Ajax post in the razor view