return RedirectToAction("Index", "Dashboard");
网址应为
但这显示
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*x}", new { x = @".*\.asmx(/.*)?" });
routes.IgnoreRoute("{resource}.ashx/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "UserLogin", action = "Index", id = UrlParameter.Optional }
);
}
答案 0 :(得分:2)
这可能是因为您的路线配置包含类似
的内容routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
默认操作的位置为Index
这意味着,当你执行RedirectToAction("Index", "Dashboard");
时,它会忽略索引,因为这已经是默认值。
答案 1 :(得分:1)
可能这个可以帮助你,在你的应用程序中设置web.config
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"></modules>
<handlers>
<remove name="UrlRoutingHandler"/>
</handlers>
</system.webServer>
你也可以这样做,
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>