R
R.A.M.
Hello,
Could you help me please with a problem of Global.asax
implementation? I have little experience.
I have written Global.asax for my ASP.NET application:
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["Users"] = 0;
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
Application["Users"] = 0;
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
Response.Redirect("Error.html");
}
void Session_Start(object sender, EventArgs e)
{
Application.Lock();
Application["Users"] = (int)Application["Users"] + 1;
Application.Unlock();
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the
sessionstate mode
// is set to InProc in the Web.config file. If session mode is
set to StateServer
// or SQLServer, the event is not raised.
Application.Lock();
Application["Users"] = (int)Application["Users"] - 1;
Application.Unlock();
}
</script>
....But it does not work the way I expected because:
Problem 1: Session_End() is not called,
Problem 2: opening my application in a new browser window does not
call Session_Start(), so users counter is not increased.
Here is my Web.Config:
<?xml version="1.0"?>
....
<configuration>
<appSettings/>
....
<system.web>
<compilation debug="true"/>
<authentication mode="Forms">
<forms name="Demo.NET" loginUrl="Default.aspx" />
</authentication>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
<customErrors mode="RemoteOnly" defaultRedirect="Error.html">
</customErrors>
<sessionState mode="InProc"
cookieless="false"
timeout="20"/>
</system.web>
</configuration>
Could you help me to solve problems 1st and 2nd?
Thank you very much!
/RAM/
Could you help me please with a problem of Global.asax
implementation? I have little experience.
I have written Global.asax for my ASP.NET application:
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["Users"] = 0;
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
Application["Users"] = 0;
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
Response.Redirect("Error.html");
}
void Session_Start(object sender, EventArgs e)
{
Application.Lock();
Application["Users"] = (int)Application["Users"] + 1;
Application.Unlock();
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the
sessionstate mode
// is set to InProc in the Web.config file. If session mode is
set to StateServer
// or SQLServer, the event is not raised.
Application.Lock();
Application["Users"] = (int)Application["Users"] - 1;
Application.Unlock();
}
</script>
....But it does not work the way I expected because:
Problem 1: Session_End() is not called,
Problem 2: opening my application in a new browser window does not
call Session_Start(), so users counter is not increased.
Here is my Web.Config:
<?xml version="1.0"?>
....
<configuration>
<appSettings/>
....
<system.web>
<compilation debug="true"/>
<authentication mode="Forms">
<forms name="Demo.NET" loginUrl="Default.aspx" />
</authentication>
<authorization>
<deny users="?" />
<allow users="*" />
</authorization>
<customErrors mode="RemoteOnly" defaultRedirect="Error.html">
</customErrors>
<sessionState mode="InProc"
cookieless="false"
timeout="20"/>
</system.web>
</configuration>
Could you help me to solve problems 1st and 2nd?
Thank you very much!
/RAM/