Recently, a small asp.net project was started. You need to log on to the entire project to perform operations. In the past, we used asp session + cookie to implement identity authentication. I have long heard of the forms authentication provided by asp.net, but I have never practiced it. Today I just caught the opportunity to apply it.
Problem: It is said that using forms authentication cannot get more information about the current Login User except the user name. After some small experiments, the userdata that comes with forms can be used as a place for us. The following is a record of my operation steps.
Step 1: Key Points of web. config Configuration:
Copy to ClipboardReference content: [www.bkjia.com] web. config Configuration
1 <! --
2. You can use the <authentication> section to configure ASP. NET
3. Identify
4. Security Authentication mode.
5 -->
6 <authentication mode = "Forms">
7 <forms loginUrl = "login. aspx" defaultUrl = "index. aspx"
8 name = ". ztinfozero" path = "/Manager"
9 slidingExpiration = "true" timeout = "10"> </forms>
10 </authentication>
11 <authorization>
12 <deny users = "? "/>
13 </authorization>
Step 2: Construct SiteUser Model
Copy to ClipboardReference: [www.bkjia.com] TopicUser Model
[Serializable]
Public class TopicUser
{
Public TopicUser (){}
Model # region model
Private System. Int32 _ autoID;
/** // <Summary>
///
/// </Summary>
Public System. Int32 autoID
{
Get {return _ autoID ;}
Set {_ autoID = value ;}
}
Private System. String _ UserName;
/** // <Summary>
/// User Name
/// </Summary>
Public System. String UserName
{
Get {return _ UserName ;}
Set {_ UserName = value ;}
}
Private System. String _ UserChName;
/** // <Summary>
/// Real name
/// </Summary>
Public System. String UserChName
{
Get {return _ UserChName ;}
Set {_ UserChName = value ;}
}
Private System. String _ UserPass;
/** // <Summary>
///
/// </Summary>
Public System. String UserPass
{
Get {return _ UserPass ;}
Set {_ UserPass = value ;}
}
Private System. String _ DepartMent;
/** // <Summary>
///
/// </Summary>
Public System. String DepartMent
{
Get {return _ DepartMent ;}
Set {_ DepartMent = value ;}
}
Private System. String _ Duty;
/** // <Summary>
///
/// </Summary>
Public System. String Duty
{
Get {return _ Duty ;}
Set {_ Duty = value ;}
}
Private System. Int32 _ UserPermit;
/** // <Summary>
///
/// </Summary>
Public System. Int32 UserPermit
{
Get {return _ UserPermit ;}
Set {_ UserPermit = value ;}
}
Private System. Int32 _ Status;
/** // <Summary>
///
/// </Summary>
Public System. Int32 Status
{
Get {return _ Status ;}
Set {_ Status = value ;}
}
# Endregion
}
- Three pages in total:
- Previous Page
- 1
- 2
- 3
- Next Page