formsauthentication

Using formsauthentication for login and use HttpContext.Current.User.Identity

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-01 06:51:33
问题 I have made a website with a page that includes a razor form. The user can login on this form and then redirects to a different page. The logging in (and logging out) works with formsauthentication succesfully. However, I can't seem to use HttpContext.Current.User.Identity.Name to retrieve the stored username (in the formsauthentication cookie). It returns an empty string "". I am using MVC 5 and ASP 4.5 with no standard membership or role providers. Login: [HttpPost] public ActionResult

Formsauthentication.RedirectFromLoginPage keeps looping

痴心易碎 提交于 2019-12-24 03:04:33
问题 This is in continuation to my last question (ASP.net Custom membership on top of quality center authorization) developing asp.net application to provide an customized interface to HP's Quality center(QC). Its login page will use QC'a API for authenticating a user. Also have a SQL database in which I store the QC users who have registered to my application (just store QC user id's in DB, not password, password authentication is done using QC API). like in QC, my login page, has 2 sets of

Can System.Web be used with ASP.Net Core with Full Framework

ぐ巨炮叔叔 提交于 2019-12-09 02:23:41
问题 We are running serveral sites based on different .Net versions. One of the sites is running .Net 4.6 and ASP.Net MVC 5.xx To use the new syntax for Razor we want to upgrade this site to use .Net 4.6 and ASP.Net Core We use FormsAuthentication on our sites, and we will continue using that so user can move between sites. (one of the sites is a SharePoint site running FormsAuthentication) We understand that ASP.Net Core is not using anything from System.Web but we need to use that from

FormsAuthentication isn't preserving the UserData field after Postback in .NET 3.5

会有一股神秘感。 提交于 2019-12-05 05:19:14
问题 I've created a FormsAuthenticationTicket from scratch, but found that when retrieving it at a later time, the UserData isn't coming back. Here is the code used: FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, user.UserId, DateTime.Now, DateTime.MaxValue, false, user.UserType); HttpCookie cookie = new HttpCookie( FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket)); Response.Cookies.Add(cookie); However, when reading this back on the next Request , I

FormsAuthentication isn't preserving the UserData field after Postback in .NET 3.5

∥☆過路亽.° 提交于 2019-12-03 20:34:25
I've created a FormsAuthenticationTicket from scratch, but found that when retrieving it at a later time, the UserData isn't coming back. Here is the code used: FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, user.UserId, DateTime.Now, DateTime.MaxValue, false, user.UserType); HttpCookie cookie = new HttpCookie( FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(ticket)); Response.Cookies.Add(cookie); However, when reading this back on the next Request , I found that the UserData field is now empty: string encryptedCookie = Request.Cookies[

FormsAuthenticationTicket.expiration v web.config value timeout

梦想的初衷 提交于 2019-12-03 09:13:04
问题 This is an MVC2 website, I am having a problem with a FormsAuthentication ticket. A user timeouts after 30 minutes cannot re-login. During testing, the DateTime.Now.AddMinutes(30) value was set to 5000 and everything was ok, but it has now changed to 30 and that is when then the problem started From cookie creation FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, user.UserID, DateTime.Now, DateTime.Now.AddMinutes(30), false, "user,user1", FormsAuthentication

FormsAuthenticationTicket.expiration v web.config value timeout

▼魔方 西西 提交于 2019-12-03 00:46:15
This is an MVC2 website, I am having a problem with a FormsAuthentication ticket. A user timeouts after 30 minutes cannot re-login. During testing, the DateTime.Now.AddMinutes(30) value was set to 5000 and everything was ok, but it has now changed to 30 and that is when then the problem started From cookie creation FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, user.UserID, DateTime.Now, DateTime.Now.AddMinutes(30), false, "user,user1", FormsAuthentication.FormsCookiePath); Web.config file <authentication mode="Forms"> <forms loginUrl="~/Account.mvc/LogOn" timeout="2880"

Why is ASP.NET FormsAuthentication cookie not authenticating user?

一世执手 提交于 2019-12-02 01:29:07
问题 I have a site that uses the default SqlMembershipProvider and FormsAuthentication. I can use the built-in Login Controls and/or programmatically call all the methods to authenticate a user and get the same result - the user is authenticated and a cookie is created, but the cookie does not appear to be valid since I can't get into any page that requires authentication. There is no real code to show for the default Login Control since it should just "work", but here is the custom code I tried:

Why is ASP.NET FormsAuthentication cookie not authenticating user?

南楼画角 提交于 2019-12-01 23:40:59
I have a site that uses the default SqlMembershipProvider and FormsAuthentication. I can use the built-in Login Controls and/or programmatically call all the methods to authenticate a user and get the same result - the user is authenticated and a cookie is created, but the cookie does not appear to be valid since I can't get into any page that requires authentication. There is no real code to show for the default Login Control since it should just "work", but here is the custom code I tried: protected void ctrlLogin_Authenticate(object sender, AuthenticateEventArgs e) { if (Membership

Can System.Web be used with ASP.Net Core with Full Framework

≡放荡痞女 提交于 2019-12-01 03:04:32
We are running serveral sites based on different .Net versions. One of the sites is running .Net 4.6 and ASP.Net MVC 5.xx To use the new syntax for Razor we want to upgrade this site to use .Net 4.6 and ASP.Net Core We use FormsAuthentication on our sites, and we will continue using that so user can move between sites. (one of the sites is a SharePoint site running FormsAuthentication) We understand that ASP.Net Core is not using anything from System.Web but we need to use that from controllers (to create FormsAuthentication cookie during login) and from HttpModule to verify cookie. I have not