simplemembership

How would I mimic User.IsInRole()

空扰寡人 提交于 2019-11-30 07:39:49
I have a website thats build with VS 2012 Internet Application ( Simple membership) EF Code First Updates I would like to know how to extend HttpContext.User.IsInRole(role) 's functionality for a custom table -> User.IsInClient(client) . Here is the way I'd suggest to solve your issue: Create your own interface which implements System.Security.Principal , where you could place any methods you need: public interface ICustomPrincipal : IPrincipal { bool IsInClient(string client); } Implement this interface: public class CustomPrincipal : ICustomPrincipal { private readonly IPrincipal _principal;

How to migrate from SimpleMembership to ASP.NET.Identity

与世无争的帅哥 提交于 2019-11-30 06:39:34
问题 Migrating from MVC4 to MVC5 and want to use ASP.NET Identity too but I am struggling to find anything that covers everything I think I need to do to migrate the Identity. Migrating an Existing Website from SimpleMembership to ASP.NET Identity suggests all I need to do is create an ApplicationUser and migrate the data, and other web searches give me sql scripts and passowrd hashing advice. But there are other loose ends that I'd like to clear up before I jump in. First - I have code to

Why InitializeSimpleMembershipAttribute in MVC 4 app

安稳与你 提交于 2019-11-30 04:39:39
I think my understanding on SimpleMembershipProvider is almost 60% and the rest is getting to know how it internally work. You can quickly found some issue when using [InitializeSimpleMembership] filter only in AccountController (the default template). I think anywhere you use Memberhsip API or WebMatrix.WebSecurity , you need to make sure this filter should be called first. Later, If you use User.IsInRole in my _Layout.cshtml . You need to apply the filter to all controllers, then you start registering it in globally. However I just realize there is LazyInitializer.EnsureInitialized which

How to get error details on Azure Web site

岁酱吖の 提交于 2019-11-30 02:58:44
I'm new to Azure. Does anybody know how get detailed error message on website deployed to Azure web? I added SimpleMembership to website and now Registration and Login (Post) are showing Sorry, an error occurred while processing your request. I'm connecting to DB on my home computer (no problem with connection). LogFiles folder on azure ftp server has some files but I don't see how to use this information. I wish I can get YellowScreen on azure... You have two options: First, you can turn off custom errors in your web config. This is the quick-and-dirty approach but it will at least get you

SimpleMembership, MVC4, AuthorizeAttribute and Roles

帅比萌擦擦* 提交于 2019-11-30 02:45:11
I’m trying to add authorize attributes to some of my MVC4 controllers, and they work fine as long as it’s a plan [Authorize] or [Authorize(Users="myuser")] , but the second I add in any sort of role filtering it falls apart, eg. [Authorize(Roles="admin")] . I then start getting errors like: Server Error in '/' Application. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network

How to check user is in many roles in asp.net identity

橙三吉。 提交于 2019-11-29 15:43:22
Hi I need to check if a user is in one of the roles and i am confused with different versions of code that i found. Let me show you what i have at the moment first _manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>()); var currentUser = _manager.FindById(User.Identity.GetUserId()); if (!_manager.IsInRole(currentUser.Id, "admin")) { } And ApplicationUser public class ApplicationUser : IdentityUser { } public class ApplicationDbContext : IdentityDbContext<ApplicationUser> { } So i want to check if the user is in one of the roles. e.g. admin, controbutor, superuser, etc. I

webpages_UsersInRoles missing

浪子不回头ぞ 提交于 2019-11-29 10:54:53
I am using ASP.NET MVC 4 together with SimpleMemmbership. When I built my application the following tables were built automatically webpages_Membership webpages_OAuthMembership webpages_Roles I can successfully register users. However, the webpages_UsersInRoles table seems to be missing. Does anyone know why this table is missing? This article might assist you in resolving your issue. Update: The article above got us going in the right direction. Our solution was to add a definition for "webpages_UsersInRoles to our UserProfile.cs class that gets used during initialization (we are doing code

ASP.NET MVC 4, The “WebSecurity.InitializeDatabaseConnection” method can be called only once

青春壹個敷衍的年華 提交于 2019-11-29 10:22:27
I am developing a code first web app in Visual Studio 2012 Express. I use this connection string in the web.config: <add name="myContext" connectionString="Data Source=.;Integrated Security=True;Initial Catalog=cityKingMVC4" providerName="System.Data.SqlClient" /> I am using SimpleMembership. I am trying to seed 1 administrator from Filters/InitializeSimpleMembershipAttribute.cs: ... WebSecurity.InitializeDatabaseConnection("myContext", "Users", "UserId", "Email", autoCreateTables: true); // A: Create Admin user if (!WebSecurity.ConfirmAccount("admin@mydom.com")) { WebSecurity

How would I mimic User.IsInRole()

大憨熊 提交于 2019-11-29 09:40:29
问题 I have a website thats build with VS 2012 Internet Application ( Simple membership) EF Code First Updates I would like to know how to extend HttpContext.User.IsInRole(role) 's functionality for a custom table -> User.IsInClient(client) . 回答1: Here is the way I'd suggest to solve your issue: Create your own interface which implements System.Security.Principal , where you could place any methods you need: public interface ICustomPrincipal : IPrincipal { bool IsInClient(string client); }

Why InitializeSimpleMembershipAttribute in MVC 4 app

混江龙づ霸主 提交于 2019-11-29 02:28:29
问题 I think my understanding on SimpleMembershipProvider is almost 60% and the rest is getting to know how it internally work. You can quickly found some issue when using [InitializeSimpleMembership] filter only in AccountController (the default template). I think anywhere you use Memberhsip API or WebMatrix.WebSecurity , you need to make sure this filter should be called first. Later, If you use User.IsInRole in my _Layout.cshtml . You need to apply the filter to all controllers, then you start