User first log and another logs. Stats for users, etc.


Hello!
I will write what I have.
I have simple membership provider and login/register control. But when the new user come to site, he can sign up. After click "Finish" or "Register" button, his account is saving, but is inactivate. He also gets an email with link to active the account ( link is like: http://mysite.com/activate.aspx?id=XXXXXX, where XXXXXX is simply his GUID number, so activating user is very easy - aproove user where userId = GUID). Ok.
 
But I have problem. How to make simply logger counter for each user ?
Simply: "Hello User, this is your 123 log on this portal" 
My question is about how can I easily set that when the user is logged correctly, his counter is increasing "by one" +1?
Is it the best way to save this log counter to his profile ?
 
And another question. How to start making a statistic engine for site ?
For now, only idea is to write a code in global.asax (OnSessionStart) that is getting simply IP,date time, etc and putting this informations to the database ? Or there is better way ?
 
0
Grzesiek23
12/19/2006 3:01:31 PM
📁 asp.net.security
📃 27051 articles.
⭐ 1 followers.

💬 6 Replies
👁️‍🗨️ 1215 Views


Any ideas ?

0
Grzesiek23
12/19/2006 10:53:12 PM

Noone ?
 
0
Grzesiek23
12/20/2006 3:44:33 PM
^ Up
0
Grzesiek23
12/21/2006 4:33:18 PM
First of all you need to save the count of the access times for each user in some where, Profile properties is a good choice for this. For example:

<profile automaticSaveEnabled="true" enabled="true" defaultProvider="SqlProvider">
<providers>
<clear />
<add name="SqlProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="LocalSqlServer"
applicationName="/"
description="SqlProfileProvider for SampleApplication" />
</providers>
<properties>
<add name="LogonCount" defaultValue="1" type="System.Int32"/>
</properties>
</profile>
Note: the reason why I set the defaultValue of LogonCount to 1 is that I set CreateUserWizard.LoginCreatedUser="true".
Then in the Login.LoggedIn event you can increase the user's LogonCount by 1:
script runat="server">
protected void OnLoggedIn(object sender, EventArgs e)
{
ProfileCommon pc = Profile.GetProfile(Login1.UserName);
pc.LogonCount++;
pc.Save();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title> <meta name="viewport" content="width=device-width">
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:LoginStatus ID="LoginStatus1" runat="server" >
</asp:LoginStatus>
<asp:LoginView ID="LoginView1" runat="server">
<LoggedInTemplate>
<asp:Label runat="server" ID="lable1" ForeColor="red" Text='<%# "Hello "+DataBinder.Eval(User.Identity,"Name")+", this is your "+DataBinder.Eval(Profile,"LogonCount")+" log on this portal" %>'></asp:Label>
</LoggedInTemplate>
</asp:LoginView>

</div>
</form>
</body>
</html>


Welcome to my SQL/ASPNET forum for Chinese 
http://51up.org/bbs/forumdisplay.php?fid=38
0
Iori_Jay
12/25/2006 7:32:06 AM

It's OK. But I have another problem with this way - when I convert login control to template and then try to log, the LoggedIn event is ignoring - I don't know why.
 
Can anyone help me ? 
0
Grzesiek23
4/19/2007 12:13:09 PM

I don't know why, but this works fine:
 
        Dim pc As ProfileCommon = Profile.GetProfile(CType(Login1.FindControl("UserName"), TextBox).Text)
        pc.LogCount += 1
        pc.Save()

0
Grzesiek23
4/19/2007 7:20:27 PM
Reply: