Why session_End calls frequently

Posted by Abhi_patil under ASP.NET on 4/16/2009 | Views : 2630 | Status : [Member] | Replies : 6
i have used 20 min session time out.
also i have enter error string in to data base when application error comes.
i.e
void Application_Error()
{
//get last error
//add to the database.
}

application working fine.
but database table contain lot of entries of error : " Object reference not set to an instance of an object.||App_global.asax.mgnjjwfp||Void Session_End(System.Object, System.EventArgs) "

why these entries made...
plz help.
thanks.




Responses

Posted by: Vuyiswamb on: 4/16/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Afternoon Abhi_patil

Errors in the Application Occur frequently especially if the Application is its beta version. Logging Errors is a good idea but its resource consuming especially when you do it on the Database. the above error object not set for an instance of an object is a common that occurs if you dont initialize your objects correctly or if you dont trap the user input , You must stop the assupmtion that the user will pass a legitimate input to your application. You must trap your users input and check the session variables for nulls or empty string before you use them. another thing that i see from your error is that
It is often useful to know for a given request whether the user's session information is still present. The technique demonstrated is a straightforward implementation that can be easily applied to an entire web site that uses cookie based ASP.NET Session objects.

Thank you for Posting at DotnetFunda

Were Looking Forward for you reply

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhi_patil on: 4/16/2009 [Member] Starter

Up
0
Down
i have checked null values on all pages before they used,

i have checked it like that..

if(session["Username"].tostring()=="")
{
//form authentication.
}
else
{
}

and also given on master page

if(session["Username"].tostring()=="")
{
Response.Redirect("login.aspx");
}
else
{
}




Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhi_patil on: 4/16/2009 [Member] Starter

Up
0
Down
One more thing i observed in database that the entries are made after each 20 second.

but my session time out is 20 min.

<sessionState cookieless="false" timeout="20" mode="InProc" />
also in Aplication_Start()
{
Session.Timeout = 20;
}

but i have given in web.config

<authentication mode="Forms">
<forms timeout="20" loginUrl="Login.aspx" ></forms>
</authentication>

is that time is 20 min or 20 sec.

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 4/16/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Its 20 Minutes, Try to check the timeout of the session on the IIS tell me what it says

Thank you for posting at Dotnetfunda
[Administrator]

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Abhi_patil on: 4/16/2009 [Member] Starter

Up
0
Down
one more thing is that when i was testing session time out on local m/c by keeping break points, for time out i am checking user name, but some time i got it was coming to session time out any time and user name was null. but it didn't affect on regular execution. apllication working fine.

thank you.. u keep ur ans. i will reply u tommarrow. it's comapany closing time.
Thanks.

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 4/16/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
You Welcome am Alyways here :)

Thank you for posting at Dotnetfunda
[Administrator]

Abhi_patil, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response