2.0: unexpacted Application_Error

R

R.A.M.

Hello,
I have a problem with unexpected Application_Erro().
I have ASP.NET application with start page Default.aspx containg
<asp:placeHolder ID="Place" runat="server" />
for custom login control.
Here is Default.aspx.cs:

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)
{
e.Authenticated = (UserName != "" && Password == "demo");
}
}
private void Page_Load(object sender, EventArgs e)
{
Browser.Text = Request.Browser.Browser + " " +
Request.Browser.Version;
Platforma.Text = Request.Browser.Platform;
Place.Controls.Add(new DemoLogin("Login"));
Session["User"] = Application["Users"];
}
}

PROBLEM: After running Page_Load I receive infinite sequence of
unexpected Application_Error() and then Session_Start().
Here is Global.asax:

<script runat="server">
void Application_Start(object sender, EventArgs e)
{
Application["Users"] = 0;
}
void Application_End(object sender, EventArgs e)
{
Application["Users"] = 0;
}
void Application_Error(object sender, EventArgs e)
{
Response.Redirect("Problem.html");
}
void Session_Start(object sender, EventArgs e)
{
Application.Lock();
Application["Users"] = Convert.ToInt32(Application["Users"]) +
1;
Application.UnLock();
}
void Session_End(object sender, EventArgs e)
{
Application.Lock();
Application["Users"] = Convert.ToInt32(Application["Users"]) -
1;
Application.UnLock();
}
</script>

The problem appeared a few days ago, application has been working for
a few months without problem, I changed nothing.
Could you explain me the problem plase?
Thank you very much!
/RAM/
 
G

Guest

The first thing to attend to is to take the time to wrap your Page_Load
handler code in a try / catch block and actually output the Exception Message
and StackTrace properties so you can get an idea of what actually happened.
Right now, your code doesn't do any of that so how can you reasonably expect
to be able to diagnose the issue?

Peter
 
R

R.A.M.

The first thing to attend to is to take the time to wrap your Page_Load
handler code in a try / catch block and actually output the Exception Message
and StackTrace properties so you can get an idea of what actually happened.
Right now, your code doesn't do any of that so how can you reasonably expect
to be able to diagnose the issue?

Peter

I did what you suggested - that's how I diagnosed the isue. In my post
I simplified my code - just removed diagnosing code.
 

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,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top