473,322 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

2.0: unexpacted Application_Error

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/
May 29 '06 #1
2 1011
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

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"R.A.M." wrote:
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/

May 29 '06 #2
On Mon, 29 May 2006 08:48:01 -0700, Peter Bromberg [C# MVP]
<pb*******@yahoo.nospammin.com> wrote:
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.
May 30 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Greg Burns | last post by:
I am trying to write a global custom error page. I thought I would jot down some of what I've learned so far... At first I just used the default customErrors section with a defaultRedirect tag,...
3
by: tafs7 | last post by:
My code below is supposed to email me when an error occurs on the application, but it's not emailing anything. Am I missing something? I know the smtp servers I've tried work. I even added a...
0
by: Michael | last post by:
Hi, I have an ASP.NET application that catches un-handled exceptions in the Application_Error method and writes the details to the Event Log. But, if I do a Server.ClearError() followed by either...
6
by: Matt | last post by:
Can anyone give me a good reason to use BOTH application scope Page_Error and the page scope Page_Error when trapping errors in a web application? Is there any real benefit to using the Page_Error...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.