Я изучаю, как использовать профиль, который поставляется с членством и ролью в .NET. Однако я не уверен, где находится вершина цепочки для установки значения:
//Q1. Does it mean I set auth manually when loading user, or create it if not already exists?
//Or am I meant to get the isauth value from somewhere and pass it in?
var currentUserProfile = ProfileBase.Create(Membership.GetUser().UserName, isauth);
var anyUserProfile = ProfileBase.Create(strNewUser, isauth);
//isauth: true to indicate the user is authenticated;
// false to indicate the user is anonymous.
И чтобы получить значение:
//Q2. Are res1 and res2 below reflecting the same thing?
//Gets a value that indicates whether the user has been authenticated
bool res1 = HttpContext.Current.User.Identity.IsAuthenticated;
//Gets a value indicating whether the user profile is for an anonymous user
bool res2 = HttpContext.Current.Profile.IsAnonymous;
Меня смущает отношение auth / anonymous в каждом из них. Какой из них является правильным способом получить / установить пользователя для аутентификации или анонимности? Моя цель здесь - дать возможность анонимным и аутентифицированным пользователям иметь профиль.