Last post Oct 20, 2015 03:06 AM by Weibo Zhang
Oct 17, 2015 04:36 PM|brucey|LINK
kind of losing the plot here.....
I'm trying to access the Membership object to find the userID but getting loads of errors loads.
I take it we don't use Membership with 4.5 does anyone know the syntax to find a userID ?
This code works with 4.0 .net as I have used before!
private void IsUserAdmin()
string username = Page.User.Identity.Name;
var user = Membership.GetUser(username);
if (user != null)
Guid userID = new Guid(user.ProviderUserKey.ToString());
TyrescannerWebApp.IdentityModel.TyreScannerEntities dbcontext = new TyrescannerWebApp.IdentityModel.TyreScannerEntities();
var query = from p in dbcontext.Link_OrderProduct
GridView1.DataSource = query.ToList();
Oct 17, 2015 04:43 PM|PatriceSc|LINK
It's best to always tell which error you have (or the best English translation you can). Could it be that you are using ASP.NET Identity rather than Membership? See
In this case you would use
https://msdn.microsoft.com/en-us/library/microsoft.aspnet.identity.identityextensions.getuserid(v=vs.108).aspx (which is an extension method).
Oct 17, 2015 05:03 PM|brucey|LINK
The errors I was receiving are in relationship to Membership and I am using ASP.NET Identity,
basically I’m trying to identify the userID, not sure how to implement this new syntax
public static string GetUserId(
this IIdentity identity
Any help or pointers much appreciated, still learning….
Oct 20, 2015 03:06 AM|Weibo Zhang|LINK
The “public static string GetUserId(this IIdentity identity)” is an Extension Method and the following link is about the Extension Methods (C# Programming) you could have a look.
The following article you could have a look that talks about the similar issue.
I hope it’s useful to you.