2017-02-26 18 views
0

我已经改变了默认路由配置到另一个控制器和动作像下面如何重定向注销并登录到另一个CONTROLER和行动

routes.MapRoute(
      name: "Default", 
      url: "{controller}/{action}/{id}", 
      defaults: new { controller = "Products", action = "Index", id = UrlParameter.Optional }, 
      namespaces: new string[] { "WebStore.Controllers" } 
     ); 

前:

controller:Home 
action:Index 

现在:

controller:Products 
    action:Index 

现在登录和注销后,它又回到(家/索引),而我想要它去

Products/Index 
+0

你需要从的AccountController 改变你有2个功能注销等( )和登录 – liran

+0

请提供更多代码示例。 –

回答

0

您必须告诉您的登录和注销操作接下来要去哪里。

你可以简单地做:

public ActionResult login(string username, string password) 
{ 
// your login code 
return Redirect("/"); 
} 

public ActionResult logoff() 
{ 
// your log off code 
return Redirect("/"); 
} 

,或者如果您使用的子域,你可以告诉它重定向到具体路线:

return RedirectToRoute("Default", new { controller = "", action = "" }); 
相关问题