gpt4 book ai didi

asp.net-mvc-2 - RedirectToAction 返回错误的网址

转载 作者:行者123 更新时间:2023-12-04 06:49:37 24 4
gpt4 key购买 nike

我有以下 View 结构:

Home    IndexSecurity     Accounts          LogOn

The following code in the LogOn action causes a redirect to http://localhost/Security/Home/Index instead of http://localhost/Home/Index

return RedirectToAction("Index", "Home");

这是我的每个路线注册码:


   routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new {controller = "Home", action = "Index", id = UrlParameter.Optional} // Parameter defaults
);

安全
public override void RegisterArea(System.Web.Mvc.AreaRegistrationContext context) {
context.MapRoute(
"Security_default",
"Security/{controller}/{action}",
new { action = "LogOn" }
);
}

非常感谢任何帮助。

最佳答案

尝试重定向到空字符串区域:

return RedirectToAction("Index", "Home", new { area = "" });

关于asp.net-mvc-2 - RedirectToAction 返回错误的网址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3314037/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com