ورود

View Full Version : Session_Onend



Evil 69
دوشنبه 24 فروردین 1388, 23:12 عصر
سلام .

من در مورد رویداد Session_onend به مشکل خوردم .
این رویداد فقط زمانی رخ میده که Timeout ُتموم شده باشه حتی اگر کاربر صفحه سایت رو بسته باشه .
حالا من که می خوام در زمان بسته شدن صفحه ie یک سری کار انجام بدن با مشکل بر خورد می کنم می خواستم ببینم کسی راه حلی داره که بتونیم با اون این رویداد رو درست زمانی که صفحه IE بسته می شه Run کنیم ؟

البته من این رو پیدا کردم ولی راستش نفهمیدم چطوری باید ازش استفاده کنم:گیج:


I have found that a classic ASP application that worked just fine on IIS 5.0 and IIS 6.0 may have some problems in IIS 7.0 if it is making use of the Session_OnEnd function in Global.asa.
Here is the set up, I have a very simple global.asa file which increments SessionCount in Session_OnStart and decrements SessionCount in Session_OnEnd:
Sub Session_OnStart
Application("SessionCount")=Application("SessionCount")+1
End Sub
Sub Session_OnEnd
Application("SessionCount")=Application("SessionCount")-1
End Sub

and a very simple asp page which reports the value of SessionCount.
<%
response.write("Session Counter Equals: ")
response.write(Application("SessionCount"))
%>


Seems simple enough right?
Well it is, and on IIS 5.0 and IIS 6.0 this simple set up works just as expected. However, on IIS 7.0 the session count never decrements.
To allow Session_OnEnd to execute correctly we need to set RunOnEndAnonymously=False. To set this value we just need to run this command:
appcmd set config /section:system.webServer/asp /runOnEndAnonymously:false

Once this change is made the applicationhost.config should have the following entry:
<system.webServer>
<asp runOnEndAnonymously="false" />
</asp>
</system.webServer>

After this the Session_OnEnd event should fire and run successfully.

این طرف هم با IIS 7 مشکل داشته که البته مشکلشو رفع کرده ولی من که نفهمیدم چطوری