2.0: unexpected Application_Error

R

R.A.M.

Hello.
I need your help in the following problem:
I have ASP.NET application with starting page Default.aspx.
On Default.aspx.cs page I have (.aspx contains no code):

public partial class DefaultPage : System.Web.UI.Page
{
class DemoLogin : Login
{
public DemoLogin(string ID) : base()
{
this.ID = ID;
DestinationPageUrl = "Welcome.aspx";
TitleText = "<b>Logging in</b>";
UserNameLabelText = "User";
PasswordLabelText = "Password";
PasswordRequiredErrorMessage = "Password required.";
LoginButtonText = "Login";
LoginButtonType = ButtonType.Button;
RememberMeSet = true;
RememberMeText = "Remeber";
InstructionText = "<i>Enter any username and password
\"demo\".</i>";
FailureText = "Failure. Try again.";
}
override protected void OnAuthenticate(AuthenticateEventArgs
e)
{

System.Diagnostics.Debug.WriteLine("DefaultPage.DemoLogin.OnAuthenticate()");
e.Authenticated = (UserName != "" && Password == "demo");
}
}
private void Page_Load(object sender, EventArgs e)
{
System.Diagnostics.Debug.WriteLine("DefaultPage.Page_Load()");
Browser.Text = Request.Browser.Browser + " " +
Request.Browser.Version;
Platforma.Text = Request.Browser.Platform;
Place.Controls.Add(new DemoLogin("Login"));
Session["Users"] = Application["Users"];
}
}

QUESTION: I don't understand why *after* Page_Load() I got a call to
Application_Error(). I tried to debug, everything in Default.aspx.cs
works fine.
Here's my Global.asax:

<%@ Application Language="C#" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Diagnostics" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
Debug.WriteLine("Application_Start()");
Application["Users"] = 0;
}
void Application_End(object sender, EventArgs e)
{
Debug.WriteLine("Application_End()");
Application["Users"] = 0;
}
void Application_Error(object sender, EventArgs e)
{
Debug.WriteLine("Application_Error()");
Response.Redirect("Problem.html");
}
void Session_Start(object sender, EventArgs e)
{
Application.Lock();
Application["Users"] = Convert.ToInt32(Application["Users"]) +
1;
Application.UnLock();
Debug.WriteLine("Session_Start(): users: " +
Application["Users"].ToString());
}
void Session_End(object sender, EventArgs e)
{
Application.Lock();
Application["Users"] = Convert.ToInt32(Application["Users"]) -
1;
Application.UnLock();
Debug.WriteLine("Session_End(): users: " +
Application["Users"].ToString());
}
</script>

Please help.
Thank you very much.
/RAM/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top