forms-authentication

FormsAuthentication Roles without Membership

浪子不回头ぞ 提交于 2019-12-18 12:28:33
问题 I'm trying to use FormsAuthentication and it's working fine at the moment with user name and password. I need to add User Role to the Forms authentication Ticket and i'm not using ASP.NET Membership. if (rep.CheckUser(model.UserName, model.Password,out UserRole))//Check User { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); // Roles.AddUserToRole(model.UserName, UserRole);//This Requires Membership return Redirect(FormsAuthentication.DefaultUrl); } 回答1:

Remember me functionality in ASP.NET Form Authentication doesn't work

大憨熊 提交于 2019-12-18 11:56:29
问题 I'm using ASP.NET forms authentication for logging users into a website we're developing. Part of the functionality is a "Remember me" checkbox which remembers the user for a month if they check it. The code for logging the user in is as follows: public static void Login(HttpResponse response, string username, bool rememberMeChecked) { FormsAuthentication.Initialize(); FormsAuthenticationTicket tkt = new FormsAuthenticationTicket(1, username, DateTime.Now, DateTime.Now.AddMinutes(30),

How to force logout user when his/her username is changed by another user?

試著忘記壹切 提交于 2019-12-18 11:28:59
问题 In my application I am using Forms-Authentication to sign in and sign out users. One functionality is admin can change the username of other users. In that case, I need to sign out the user whose username is changed. If I do not, due to their cookies set before, they gain access to application and receive error messages (since their username does not exist and there are parts where I use their username for some functionality). How can I force these users to log out using Forms-Authentication

Sharing a cookie between two websites on the same domain

China☆狼群 提交于 2019-12-18 10:53:11
问题 Here's the situation: Website A, ASP.NET MVC 4 web application. Domain: http://a.example.com Website B, ASP.NET MVC 4 web applicaiton. Domain: http://b.example.com I'm trying to share a cookie (forms authentication) between the websites. I'm not using Forms Authentication per-se. I'm using the built-in methods (Encrypt, Decrypt, etc), but I'm setting my own custom cookie. When I set the cookie on one of the websites, the other ones sees the cookie, but can't decrypt it. The error is the

How can I unit test my ASP.NET MVC controller that uses FormsAuthentication?

自古美人都是妖i 提交于 2019-12-18 10:27:28
问题 I'm working with a ASP.NET MVC solution in a test driven manner and I want to login a user to my application using forms authentication. The code I would like to end up with in the controller looks something like this: FormsAuthentication.SetAuthCookie(userName, false); My question is how do I write a test to justify this code? Is there a way to check that the SetAuthCookie method was called with the correct parameters? Is there any way of injecting a fake/mock FormsAuthentication? 回答1: I

How can I unit test my ASP.NET MVC controller that uses FormsAuthentication?

你离开我真会死。 提交于 2019-12-18 10:27:05
问题 I'm working with a ASP.NET MVC solution in a test driven manner and I want to login a user to my application using forms authentication. The code I would like to end up with in the controller looks something like this: FormsAuthentication.SetAuthCookie(userName, false); My question is how do I write a test to justify this code? Is there a way to check that the SetAuthCookie method was called with the correct parameters? Is there any way of injecting a fake/mock FormsAuthentication? 回答1: I

AngularJS + ASP.NET Web API + ASP.NET MVC Authentication

南楼画角 提交于 2019-12-18 10:05:06
问题 I am new to AngularJS and trying to evaluate it for my new web application. Requirement: I will have one ASP.NET Web API which will be consumed from an Android, an iPhone and from a web application (ASP.NET MVC) too. ASP.NET Identity will be implemented in Web API. All three applications will call the login method of Web API to get the auth token. Problem: My problem is how to get ASP.NET MVC server side authentication work (in sync with Web API so I don't have to login for ASP.NET MVC

System.Web.HttpContext.Current.User.Identity.IsAuthenticated fails sometimes

二次信任 提交于 2019-12-18 07:17:28
问题 I have been having trouble with my production site (not my development sites). Every now and then both Firefox and Chrome fail to log users in (all users both on our client network and general web). But the strange part is that Internet Explorer always works correctly and has NEVER failed once (I have delete cache and cookies in browsers but still the same thing happens). Then after an hour or X amount of time, Firefox and Chrome start behaving normally again. I have a narrowed it down to

ASP.NET Web Service inside Forms Authentication Application

走远了吗. 提交于 2019-12-18 06:23:30
问题 I have an existing ASP.NET application that implements Forms Authentication site-wide. The application is deployed in multiple instances (e.g., customer1, customer2, test, dev, etc...), with a separate database per instance. SSL is in play. Instance configuration is via an XML config file. I have a new requirement to allow upload/download of certain data, which I would like to implement as a public web service. My initial thought here was to selectively disable forms authentication for a

asp.net forms authentication logged out when logged into another instance

*爱你&永不变心* 提交于 2019-12-18 05:18:15
问题 I am doing some development on my local machine using VS 2010 and running my dev code in Cassini, I also have taken a copy of the same code and deployed it to c:\mp and setup a web application in IIS7 to point to this directory. Both applications are pointing to different databases. I access the IIS one by http://localhost/mp When I log into either one of these it results in my being logged out from the other if I am already logged in. I have a feeling this is something to do with the forms