4

.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の関係について混乱しています。ユーザーを認証または匿名にするための正しい方法はどれですか?ここでの私の目標は、匿名ユーザーと認証済みユーザーの両方がプロファイルを持つことができるようにすることです。

4

1 に答える 1

2

res1とはres2、値がIIS構成の設定に依存するため、異なります。

IISで「匿名アクセス」を有効にして、匿名IDをユーザーアカウントにバインドできます

Codeprojectから:
このコードをIIS6で匿名モードで実行すると、以下に示すような詳細は表示されません。 ここに画像の説明を入力してください

asp.netの認証と承認に関する次の記事をご覧ください:http:
//www.codeproject.com/Articles/98950/ASP-NET-authentication-and-authorization

IIS7では、次のように[セキュリティ]>>[認証]に移動できます。

ここに画像の説明を入力してください

ここに画像の説明を入力してください

于 2012-06-07T07:27:37.253 に答える