ASP.NET login does not redirect just logged user properly in Firefox and IE, but works with Chrome

a 夏天 提交于 2019-12-06 05:02:36

From you web config <authentication mode="Forms">, I can deduct you are using forms authentication.

Try these two things:

  1. Set up default url in forms authentication setting like :

    <authentication mode="Forms"> <forms loginUrl="~/Account/Login" cookieless="UseCookies" timeout="30" slidingExpiration="true" defaultUrl="~/Home/Index"/> </authentication>

  2. For redirecting after authentication, instead of using return RedirectToAction("Index", "Home"); or return Redirect(returnUrl);

use FormsAuthentication.RedirectFromLoginPage method like:

if (Membership.ValidateUser(userName, password) == true)
{
   FormsAuthentication.SetAuthCookie(userName, false);
   FormsAuthentication.RedirectFromLoginPage(userName, false);
}

It Redirects an authenticated user back to the originally requested URL or the default set in the config.

For more information & override of this method refer :

Microsoft docs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!