RedirectToRoute和RedirectToAction返回区域错误的URL

时间:2019-11-15 08:23:52

标签: asp.net asp.net-mvc routing

我的项目有问题。登录成功后返回重定向页面时。我的期望链接是:/Admin/Subject/Index.cshtml。但是在调试时,URL为:/Subject/Index.cshtml?Area="Admin",但出现404错误。

return RedirectToRoute(new
{
    Areas = "Admin",
    controller = "Subject",
    action = "Index"
});

// And

return RedirectToAction("Subject", "Courses", new { areas="Admin"});

这是我的RouteConfig

app.UseMvc(routes =>
{
    routes.MapRoute(name: "MyArea",
        template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");

    routes.MapRoute(name: "default",
        template: "{controller=Main}/{action=Login}/{id?}");
});

我在做什么错了?

0 个答案:

没有答案