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

0 comments: