MVC 5 How to define Owin LoginPath with localized routes

前端 未结 8 667
有刺的猬
有刺的猬 2020-12-12 19:18

I have a MVC 5 website with localized routes defined as

routes.MapRoute(
            name: \"Default\",
            url: \"{culture}/{controller}/{action}/{         


        
8条回答
  •  一个人的身影
    2020-12-12 19:47

    I improved Sentinel answer, to keep return url:

    private static void ApplyRedirect(CookieApplyRedirectContext context)
            {
                //use this way to keep return url
                var loginUrl = context.RedirectUri.Insert(
                    context.RedirectUri.IndexOf("/Account/Login"),
                    "/" + CultureHelper.GetCurrentCulture());
    
                context.Response.Redirect(loginUrl);
            }
    

提交回复
热议问题