How to identify an anonymous profile

I am learning how to use a profile that comes with .NET membership and role. However, I'm not sure where the top of the chain is to set the value:

//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. 

And to get the value:

 //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; 

I am confused about the auth / anonymous relationship in each of them. Which one is the right way to get / establish that the user should be authenticated or anonymous? My goal here is to enable anonymous users and authenticated users to have a profile.

+4
source share
1 answer

res1 and res2 are different from each other because its values ​​depend on the settings in the IIS configuration.

You can enable Anonymous Access in IIS to associate an anonymous identity with a user account

From Codeproject:
if you run this code in IIS6 in anonymous mode, you will not receive any information as shown below. enter image description here

Take a look at the following asp.net authentication and authorization article:
http://www.codeproject.com/Articles/98950/ASP-NET-authentication-and-authorization

In IIS7, you can go to Security -> Authentication as follows:

enter image description here

enter image description here

+2
source

Source: https://habr.com/ru/post/1415143/


All Articles