我想从
更改登录重定向return RedirectToAction("Index", "Home");
要
return RedirectToAction("Foo", "Profile");
Foo动作返回一个视图。 问题是我仍然得到了家/索引。
我是否需要更改路由?
RouteConfig是这样的:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "NotFound",
url: "{*catchall}",
defaults: new { controller = "Home", action = "Index" }
);
}
答案 0 :(得分:0)
问题是登录后重定向重定向到根'/'url。 您可以通过路线重置此项。 如下所示:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Profile", action = "Foo", id = UrlParameter.Optional }
);
routes.MapRoute(
name: "NotFound",
url: "{*catchall}",
defaults: new { controller = "Profile", action = "Foo" }
);