Showing posts with label Membership Provider. Show all posts
Showing posts with label Membership Provider. Show all posts

Monday, February 4, 2013

The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'. Solved...

While working with Asp.NET and Membership, using MS SQL 2008 R2 I came across following error. My web application was working perfect on my local machine but when I hosted it on remote server I got following error.
The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'. However, the current database schema is not compatible with this version. You may need to either install a compatible schema with aspnet_regsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.
After R&D I had came across three possible solutions "WHICH I THINK ARE RIGHT, AS THEY WORKED FOR ME IN DIFFERENT SCENARIOS."

  1. Check "aspnet_SchemaVersions" table in database and make sure CompatibleSchemaVersion is set to "1" for all the Features (e.g. common, membership, role manager etc) available in table. Also make sure IsCurrentVersion column values are set to 'True" for all Features.
  2. In Web.Config, and aspnet_Applications table check if application Name is matching or not. Application name in web.config's Membership>Providers, Profile>Providers, RoleManager>Providers are matching with application name in database.
  3. In Membership>Provider I had "AspNetSqlMembershipProvider" type as type="System.Web.Security.SqlMembershipProvider" which I modified (after referring to some articles online) to type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Application worked for me when I checked all these things and made changes in my application.
Submit this story to DotNetKicks

Read more...

Sunday, November 20, 2011

Access userName asp.net-membership without using Membership.getUser()

While I was working on Membership and User Management in Asp.Net 2010
Following Scenario
  • After creating user, admin sets subscribtion for the user.
  • User logs in with id and password, after validating user, I check for subscription details.
  • If user is logging in with subscription period he/she has access to the application else he/she will be redirected to Subscription Expired page.
To check subscription, I had requirement to get username and check it in Subscription table.
I did not want to use getUser function, as I just wanted to get user name of currently logged in user.

To get user name I used following line of code

System.Web.HttpContext.Current.User.Identity.Name


Submit this story to DotNetKicks

Read more...