Is it possible to change the username with the Membership API

It’s true that the default SQL Membership Provider does not allow username changes. However, there’s no intrinsic reason to prevent users from changing their usernames if you have a valid argument, on your site, to allow it. None of the tables in the SQL database have the username as a key, everything is based on … Read more

How to add ASP.NET Membership Provider in a Empty MVC 4 Project Template?

Installing it You need to add the following Nuget Packages: EntityFramework Microsoft.AspNet.WebPages.OAuth Note: This package will install all the required dependencies automatically for you. This is a detailed list of all nuget packages installed: Microsoft.AspNet.WebPages.WebData Microsoft.AspNet.WebPages.Data DotNetOpenAuth.AspNet DotNetOpenAuth.OpenId.RelyingParty DotNetOpenAuth.OpenId.Core DotNetOpenAuth.Core CodeContracts.Unofficial DotNetOpenAuth.OAuth.Consumer DotNetOpenAuth.OAuth.Core DotNetOpenAuth.Core CodeContracts.Unofficial Add a reference to System.Transactions Testing it Now in order … Read more

Dependency injection and ASP.Net Membership Providers

If you are configuring the custom membership providers via the <membership> element in the Web.config file, then I can see the issues you will have with dependency injection. The providers are constructed and managed by the framework, and there is no opportunity for you to intercept that construction to provide additional dependency injection for the … Read more

How to combine using Membership API with own application related data?

The first is the simpliest approach. Add the GUID of the user as a foreignkey in the related tables (f.e. Ordered_by). I don’t see where it breaks separating concerns. If you want to keep the order-record in database, you also have to keep the user who has ordered, that makes perfectly sense. I have used … Read more

How do I use my own database with SimpleMembership and WebSecurity? What is MVC4 security all about?

See the summaries below each quote for a quick answer, and the paragraphs for detail. Also see the References section at the end for the authoritative sources. Summaries 1.What is SimpleMembership/SimpleMembershipProvider (WebMatrix.WebData) and what is it/are they responsible for? SimpleMembership (a term that covers both the SimpleMembershipProvider and SimpleRoleProvider) is responsible for providing a clean … Read more

SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified [closed]

If you are connecting from Windows machine A to Windows machine B (server with SQL Server installed), and are getting this error, you need to do the following: On machine B: 1.) turn on the Windows service called “SQL Server Browser” and start the service 2.) in the Windows firewall, enable incoming port UDP 1434 … Read more

Custom MembershipProvider in .NET 4.0

It’s very simple really: Create a new Class file (if you’re not using a multi-layered system, in your project’s Models folder) let’s called MyMembershipProvider.cs Inherit that class from System.Web.Security.MembershipProvider automatically create the needed methods (period + space in the inherit class) Done! All methods will have the NotImplementedException exception, all you need to do is … Read more

How do I create a custom membership provider for ASP.NET MVC 2?

I have created a new project containing a custom membership provider and overrode the ValidateUser method from the MembershipProvider abstract class: public class MyMembershipProvider : MembershipProvider { public override bool ValidateUser(string username, string password) { // this is where you should validate your user credentials against your database. // I’ve made an extra class so … Read more