Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Redirect in Controller after Authentication

$
0
0

Hi folks,

We have a custom login page in place, quite similar to <a "/blogs/Daniel-Ovaska/Dates/2016/6/creating-a-custom-login-page/">this one here.

We would like to redirect users to the backend, to be precise to "/EPiServer/CMS".

Currently, the code in the CustomLoginController looks like this:

        [HttpPost]
        [AllowAnonymous]
        [ValidateAntiForgeryToken]
        [ValidateInput(false)]
        public ActionResult LocalLogin(CustomLoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                bool result = uiSignInManager.SignIn(uiUserProvider.Name, model.Username, model.Password);
                if (result)
                {
                    return Redirect(UrlResolver.Current.GetUrl(ContentReference.StartPage));
                }
            }
            ModelState.AddModelError("LoginError", "Login failed");
            return View(Global.CustomLoginView, model);
        }

So we tried different things here to actually redirect to the backend but whatever we do we always get redirected to the StartPage / index page. Things we have tried:

return Redirect(UrlResolver.Current.GetUrl("/EPiServer/CMS"));
return Redirect("/EPiServer/CMS");
//Even those two get ignored and users get redirected to the StartPage
return Redirect("WHATEVER");
return Redirect("http://www.google.com");

Any ideas what we are doing wrong?

Best regards,

Patrick


Viewing all articles
Browse latest Browse all 9076