asp.net-membership

Having different login pages for different ASP.NET MVC 3 areas

▼魔方 西西 提交于 2019-12-18 11:45:34
问题 Can I have different login URL for different ASP .NET MVC3 areas? e.g. I would like to have different login page for Administrator and Data entry operators. I see a web.config in each area's view portion and I have tried doing: <authentication mode="Forms"> <forms loginUrl="~/Administration/Account/LogOn" timeout="2880" /> </authentication> but it does not play well. Cheers. 回答1: I'm not aware of .NET handling this for you but you could create a custom AuthorizationAttribute public class

EF Code First - Recreate Database If Model Changes

醉酒当歌 提交于 2019-12-18 10:55:18
问题 I'm currently working on a project which is using EF Code First with POCOs. I have 5 POCOs that so far depends on the POCO "User". The POCO "User" should refer to my already existing MemberShip table "aspnet_Users" (which I map it to in the OnModelCreating method of the DbContext). The problem is that I want to take advantage of the "Recreate Database If Model changes" feature as Scott Gu shows at: http://weblogs.asp.net/scottgu/archive/2010/07/16/code-first-development-with-entity-framework

ASP.Net MVC 3 Redirect UnAuthorized User not to loginUrl

送分小仙女□ 提交于 2019-12-18 10:28:54
问题 i have a project using ASP.Net MVC3 and using membership for roles. i use authorize in every controller. eg: [Authorize(Roles = "Administrator")] public ActionResult Index(string q, int i) { return View(model); } if someone doesnt have role for administrator, then it will redirect to login page by default. how to change it,so it will redirect into Views/Shared/UnAuthorize.cshtml ? or maybe if someone doesnt have role for administrator, it will show message box (alert) ? thanks in advance. 回答1

ASP.NET Membership: how to set the user as logged in

核能气质少年 提交于 2019-12-18 10:23:21
问题 I am trying to get the Membership Provider to work. So far I have: <asp:Login ID="Login1" runat="server" OnAuthenticate="Login1_Authenticate"> </asp:Login> calling : protected void Login1_Authenticate(object sender, AuthenticateEventArgs e) { if(Membership.ValidateUser(Login1.UserName, Login1.Password)) { Response.Redirect("/admin/default.aspx"); // Set the user as logged in? } } If I enter the correct login/password, the ValidateUser function returns true. So my question is: how do I set the

How can I get CURRENT USERNAME in membership asp.net 2008

做~自己de王妃 提交于 2019-12-18 03:31:07
问题 I use a membership in asp.net 2008. And I build a login system with some rolls ...etc I have a database and tables and the KEY is "username", and now I want to know how can I get a username for the member who logged in ? for example: I logged in as TURKI I want to get the username TURKI really I need for help... thanks, 回答1: User.Identity.Name User is a property of the page. If you need to access it elsewhere, you can use: HttpContext.Current.User.Identity.Name 回答2: A modification to Freddy's

Migrating from ASP.NET Membership to SimpleMembership in MVC4 RTM

╄→гoц情女王★ 提交于 2019-12-17 23:02:02
问题 The new MVC4 RTM internet application templates use the SimpleMembership providers as descibed here SimpleMembership My existing MVC website uses the ASP.Membership framework and ideally I would like to migrate the user data in these tables to the new SimpleMembership tables. My reasons for wanting to do this are: Cleaner integration with the rest of the my database which uses EF Support for Azure and OAuth out of the box Use latest MVC4 RTM Controllers/Views without needing to modify I've

Changing passwordFormat from Encrypted to Hashed

只谈情不闲聊 提交于 2019-12-17 18:11:27
问题 I'm finding surprisingly little information on converting an existing database from Encrypted passwords to Hashed passwords. (I was able to find a bit more information on converting the other way, but it wasn't of much help.) As most people know, changing the passwordFormat setting in web.config only affects new users. I have a database with a couple of hundred users and I'd like to convert them to use hashed passwords without changing those existing passwords. Is anyone else familiar with

Setting up the default AspNetSqlProvider to point to remote database

不羁的心 提交于 2019-12-17 17:52:36
问题 When starting a new project that required the use of membership providers I found that I could not connect to a remote database that contained the membership database. I ran aspnet_regsql and was able to create the membership database on the remote server but when I go to ASPNET Configuration (cassini development server) it will not connect to the remote server. 回答1: After much searching I found that the default Membership Provider specified in machine.config (c:\windows\Microsoft.NET

ASP.NET Membership/Role providers for MySQL?

核能气质少年 提交于 2019-12-17 17:48:18
问题 I am not at all familiar with ASP.NET membership/roles. This is my first time using it, and my first time trying ASP.NET MVC. When I create my first project for MVC, it gives me a lovely template to create an account. I was excited to see that I did not have to do this manually. However, it failed because it cannot connect to SQL Server. I do not have SQL Server, I have MySQL. Is there any easy way I can get this system to use MySQL instead, or will I have to create my own authentication? 回答1

How do I control MembershipProvider instance creation/lifetime?

一个人想着一个人 提交于 2019-12-17 13:05:33
问题 I have registered a custom MembershipProvider class in my Web.Config file. I'm using Inversion Of Control using Castle Windsor and I have registered my custom MembershipProvider class as transient (because it's using a service that's transient as well). This means that I want the Membership provider instance recreated on every web request. Currently, it is created only once per application domain so when it tries to access the service it depends on, that service instance is reused while it is