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 ?
Any ideas ?
Noone ?
^ Up
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:
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="LocalSqlServer"
applicationName="/"
description="SqlProfileProvider for SampleApplication" />
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();
}
Untitled Page
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 ?
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()