大佬教程收集整理的这篇文章主要介绍了asp.net – 如何在不使用FormsAuthentication.RedirectFromLoginPage时将Request.IsAuthenticated设置为true?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在这种情况下,即使在使用Membership.ValidateUser验证用户后,@R_450_10613@est.IsAuthenticated也返回false。然后我设置cookie使用
FormsAuthentication.SetAuthCookie(username,falsE);
虽然第二个参数,持久cookie,是false,cookie仍然有效跨浏览器会话。
任何想法如何使@R_450_10613@est.IsAuthenticated工作,而不使用FormsAuthentication.RedirectFromLoginPage?
public void RenewCurrentUser() { System.Web.httpCookie authCookie = System.Web.httpContext.Current.@R_450_10613@est.Cookies[FormsAuthentication.FormsCookiename]; if (authCookie != null) { FormsAuthenticationTicket authTicket = null; authTicket = FormsAuthentication.Decrypt(authCookie.value); if (authTicket != null && !authTicket.Expired) { FormsAuthenticationTicket newAuthTicket = authTicket; if (FormsAuthentication.SlidingExpiration) { newAuthTicket = FormsAuthentication.RenewTicketIfOld(authTicket); } String userData = newAuthTicket.UserData; String[] roles = userData.Split(','); System.Web.httpContext.Current.User = new System.Security.Principal.GenericPrincipal(new FormsIdentity(newAuthTicket),roles); } } }
以上是大佬教程为你收集整理的asp.net – 如何在不使用FormsAuthentication.RedirectFromLoginPage时将Request.IsAuthenticated设置为true?全部内容,希望文章能够帮你解决asp.net – 如何在不使用FormsAuthentication.RedirectFromLoginPage时将Request.IsAuthenticated设置为true?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。