Home Redirect to Action is not working With ASP.NET core
Reply: 0

Redirect to Action is not working With ASP.NET core

user1157
1#
user1157 Published in June 20, 2018, 1:27 am

I have my login view which wants to redirect to Clients page after successful login.

To do that I am using ,

[HttpPost]
        public async Task<IActionResult> Login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                var result = await _signInManager.PasswordSignInAsync(model.Username, model.Password, model.Rememberme, false);

                if (result.Succeeded)
                {

                    if (Request.Query.Keys.Contains("ReturnUrl"))
                    {
                        Redirect(Request.Query["ReturnUrl"].First());
                    }
                    RedirectToAction("Index", "Clients");
                }
                else
                {
                    ModelState.AddModelError("", "Failed to login");
                    return View();
                }
            }

            return View();

        }

But after successful login , I am staying in current login page and not redirected to Client Page!! If I try to navigate to Client page using browser this works fine without any issue.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.320778 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO