473,659 Members | 3,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Bugs found in Asp.Net application (SERIOUS)

WJ
This post is a follow up from the original post dated Oct 16, 2004 "I have
this problem, pls help!" created by Paul FI.
These bugs are rather serious and we would like to know how to get around.

Environment: Windows XP Pro. IIS-5 and Sp2.
Visual Studio.Net 2003 EA edition.
..NetFW 1.1

Here goes:

The followings are steps to reproduce two serious bugs found by Paul and
John within Asp.Net application. The application is a c# and consists of the
following items:

1. Web site: http://LocalHost/tBug
2. Four Asp.Net forms: WebForm1.Aspx (Default page), WebForm2.Aspx,
WebForm3.Aspx, and WebForm4.Aspx

Steps:

1. Create a new c-sharp (c#) Asp.Net web Project called tBug.
2. Drop a "Drop Down List Component" on WebForm1.aspx and call it "DDL", and
enable its "AutoPostBa ck".
3. Add 3 items to the DDL called Test1, Test2 and Test3 for their "Text"
property. Assign 1, 2 and 3 to their "Value" property accordingly.
4. Drop a Label compoment beside the DDL.
5. Drop two Button components on WebForm1 under the DDL and call them
Button1(Text=To WebForm2) & Button2 (Text=ToWebForm 3).
6. Double-Click on the WebForm1 itself and copy this code below onto your
WebForm1.onPage Load event:

private void Page_Load(objec t sender, System.EventArg s e)
{
if(!this.IsPost Back)
{
Label1.Text="We lcome to New tBug";
return;
}

Label1.Text="I am Back";
}

7. Double-Click on the WebForm1.DDL and copy this code below onto your
WebForm1.DDL_Se lectedIndexChan ged event:

private void DDL_SelectedInd exChanged(objec t sender, System.EventArg s
e)
{
Response.Redire ct("WebForm4.as px");
}
8. Double-Click on the WebForm1.Button 1 and copy this code below onto your
WebForm1.Button 1_Click event:

private void Button1_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct("WebForm2.as px");
}

9. Double-Click on the WebForm1.Button 2 and copy this code below onto your
WebForm1.Button 2_Click event:

private void Button2_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct("WebForm3.as px");
}
10. On the Solution Explorer, right-click on the "tBug" project and select
Add/New Asp.Net Form. Name it "WebForm2".
11. Repeat Step 10 above for WebForm3 and WebForm4.

12. Bringup WebForm2 and drop a Label component on its design surface and
assign "This is WebForm2" to its Text property.
13. Bringup WebForm3 and drop a Label component on its design surface and
assign "This is WebForm3" to its Text property.
14. Bringup WebForm4 and drop a Label component on its design surface and
assign "This is WebForm4" to its Text property.

15. Build the sulution and run it.

How to see the described BUGS:

16. Once the application is shown on the MS/IE, you should see the
Label1.Text has "Welcome to new tBug" as expected.
17. Select "Test2" from the DDL. This will bring you to WebForm4.aspx as
expected.
18. Click the "Back" button from the MS/IE tool bar. This will bring you
back to WebForm1.aspx as expected.

19. Click the "ToWebForm2 or 3" button on WebForm1, this should bring you to
"WebForm2 or 3" but "WebForm4" is shown instead.This is the "BUG" that Paul
FI talked about.

20. Click the "Back" button to go back to WebForm1 as expected.
21. Select "Test1" from the DDL, this should bring you to WebForm4, instead,
it shows "I am Back" on Webform1. This is a new BUG I found.

*************** *************** *************** ********
Below is a complete c# code-behind for WebForm1.aspx.
*************** *************** *************** ********
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;

namespace tBug
{
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Labe l Label1;
protected System.Web.UI.W ebControls.Butt on Button1;
protected System.Web.UI.W ebControls.Butt on Button2;
protected System.Web.UI.W ebControls.Labe l Label2;
protected System.Web.UI.W ebControls.Drop DownList ddl;

private void Page_Load(objec t sender, System.EventArg s e)
{
if(!this.IsPost Back)
{
Label1.Text="We lcome to New tBug";
return;
}

Label1.Text="I am Back";
}

override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}

private void InitializeCompo nent()
{
this.ddl.Select edIndexChanged += new
System.EventHan dler(this.ddl_S electedIndexCha nged);
this.Button1.Cl ick += new System.EventHan dler(this.Butto n1_Click);
this.Button2.Cl ick += new System.EventHan dler(this.Butto n2_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}

private void ddl_SelectedInd exChanged(objec t sender, System.EventArg s
e)
{
Response.Redire ct("WebForm4.as px");
}

private void Button1_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct("WebForm2.as px");
}

private void Button2_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct("WebForm3.as px");
}

}
}

Thanks for your help,

John Webb

Nov 18 '05 #1
2 1572


"WJ" wrote:
This post is a follow up from the original post dated Oct 16, 2004 "I have
this problem, pls help!" created by Paul FI.
These bugs are rather serious and we would like to know how to get around.

Environment: Windows XP Pro. IIS-5 and Sp2.
Visual Studio.Net 2003 EA edition.
..NetFW 1.1

Here goes:

The followings are steps to reproduce two serious bugs found by Paul and
John within Asp.Net application. The application is a c# and consists of the
following items:

1. Web site: http://LocalHost/tBug
2. Four Asp.Net forms: WebForm1.Aspx (Default page), WebForm2.Aspx,
WebForm3.Aspx, and WebForm4.Aspx

Steps:

1. Create a new c-sharp (c#) Asp.Net web Project called tBug.
2. Drop a "Drop Down List Component" on WebForm1.aspx and call it "DDL", and
enable its "AutoPostBa ck".
3. Add 3 items to the DDL called Test1, Test2 and Test3 for their "Text"
property. Assign 1, 2 and 3 to their "Value" property accordingly.
4. Drop a Label compoment beside the DDL.
5. Drop two Button components on WebForm1 under the DDL and call them
Button1(Text=To WebForm2) & Button2 (Text=ToWebForm 3).
6. Double-Click on the WebForm1 itself and copy this code below onto your
WebForm1.onPage Load event:

private void Page_Load(objec t sender, System.EventArg s e)
{
if(!this.IsPost Back)
{
Label1.Text="We lcome to New tBug";
return;
}

Label1.Text="I am Back";
}

7. Double-Click on the WebForm1.DDL and copy this code below onto your
WebForm1.DDL_Se lectedIndexChan ged event:

private void DDL_SelectedInd exChanged(objec t sender, System.EventArg s
e)
{
Response.Redire ct("WebForm4.as px");
}
8. Double-Click on the WebForm1.Button 1 and copy this code below onto your
WebForm1.Button 1_Click event:

private void Button1_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct("WebForm2.as px");
}

9. Double-Click on the WebForm1.Button 2 and copy this code below onto your
WebForm1.Button 2_Click event:

private void Button2_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct("WebForm3.as px");
}
10. On the Solution Explorer, right-click on the "tBug" project and select
Add/New Asp.Net Form. Name it "WebForm2".
11. Repeat Step 10 above for WebForm3 and WebForm4.

12. Bringup WebForm2 and drop a Label component on its design surface and
assign "This is WebForm2" to its Text property.
13. Bringup WebForm3 and drop a Label component on its design surface and
assign "This is WebForm3" to its Text property.
14. Bringup WebForm4 and drop a Label component on its design surface and
assign "This is WebForm4" to its Text property.

15. Build the sulution and run it.

How to see the described BUGS:

16. Once the application is shown on the MS/IE, you should see the
Label1.Text has "Welcome to new tBug" as expected.
17. Select "Test2" from the DDL. This will bring you to WebForm4.aspx as
expected.
18. Click the "Back" button from the MS/IE tool bar. This will bring you
back to WebForm1.aspx as expected.

19. Click the "ToWebForm2 or 3" button on WebForm1, this should bring you to
"WebForm2 or 3" but "WebForm4" is shown instead.This is the "BUG" that Paul
FI talked about.

20. Click the "Back" button to go back to WebForm1 as expected.
21. Select "Test1" from the DDL, this should bring you to WebForm4, instead,
it shows "I am Back" on Webform1. This is a new BUG I found.

*************** *************** *************** ********
Below is a complete c# code-behind for WebForm1.aspx.
*************** *************** *************** ********
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;

namespace tBug
{
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Labe l Label1;
protected System.Web.UI.W ebControls.Butt on Button1;
protected System.Web.UI.W ebControls.Butt on Button2;
protected System.Web.UI.W ebControls.Labe l Label2;
protected System.Web.UI.W ebControls.Drop DownList ddl;

private void Page_Load(objec t sender, System.EventArg s e)
{
if(!this.IsPost Back)
{
Label1.Text="We lcome to New tBug";
return;
}

Label1.Text="I am Back";
}

override protected void OnInit(EventArg s e)
{
InitializeCompo nent();
base.OnInit(e);
}

private void InitializeCompo nent()
{
this.ddl.Select edIndexChanged += new
System.EventHan dler(this.ddl_S electedIndexCha nged);
this.Button1.Cl ick += new System.EventHan dler(this.Butto n1_Click);
this.Button2.Cl ick += new System.EventHan dler(this.Butto n2_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}

private void ddl_SelectedInd exChanged(objec t sender, System.EventArg s
e)
{
Response.Redire ct("WebForm4.as px");
}

private void Button1_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct("WebForm2.as px");
}

private void Button2_Click(o bject sender, System.EventArg s e)
{
Response.Redire ct("WebForm3.as px");
}

}
}

Thanks for your help,

John Webb


This is a logical consequence of how the Changed events are fired and how IE
reloads pages when using the Back button. While this behavior might not be
what you wanted or expected, it doesn't represent a flaw in any particular
product, just a situation you'll have to code around to get the behavior
you're looking for. I'd suggest reading up on the Viewstate and how it
relates to tracking control values and firing the Changed events. Also note
that postback events do not have a guaranteed order, so you can never
definitively say that the button click event will execute before the list
change event (unless you do some hacking in the handlers to enforce an
ordering, which I wouldn't recommend).
For the time being, I'd suggest using caching settings to request that the
browser not cache Webform1.aspx. (Note that I say request. You cannot *force*
the browser not to cache the page, only ask it not to.) There have been a few
posts on this group on how to do this; a search should turn them up.
Nov 18 '05 #2
WJ
Though I never run into the problem. But I do tell my clients not to click
on the "Back" button, instead they always click on my application's Url Link
provided to them. This way, the described bug can be avoided without
addtional coding. As for other bug, I just plug in a dummy item that sits on
top of the drop down list and it will never be selected.

John
Nov 18 '05 #3

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

Similar topics

83
3426
by: kartik | last post by:
there seems to be a serious problem with allowing numbers to grow in a nearly unbounded manner, as int/long unification does: it hides bugs. most of the time, i expect my numbers to be small. 2**31 is good enough for most uses of variables, and when more is needed, 2**63 should do most of the time. granted, unification allows code to work for larger numbers than foreseen (as PEP 237 states) but i feel the potential for more undetected...
0
1089
by: Ayende Rahien | last post by:
Recently I've encountered two highly annoying bugs in the framework, anyone who knows how to solve them would be most appriciated. 1) I'm trying to do Process.Start(url); and get a Win32Exception, after quite a bit of testing I found out that the reason for this is that I didn't have STAThread attribute. Process.Start(url) throws when I don't have an attribute at all, or when I have MTAThrea, anyone can tell me why? I looked around, and...
10
402
by: Ayende Rahien | last post by:
Recently I've encountered two highly annoying bugs in the framework, anyone who knows how to solve them would be most appriciated. 1) I'm trying to do Process.Start(url); and get a Win32Exception, after quite a bit of testing I found out that the reason for this is that I didn't have STAThread attribute. Process.Start(url) throws when I don't have an attribute at all, or when I have MTAThrea, anyone can tell me why? I looked around, and...
2
5543
by: Lachlan Hunt | last post by:
Hi, I'm trying to implement getElementsByClass() for the document object and the Element interface, that supposed to work for HTML, XHTML, SVG and MathML class attributes (including mixed namespace documents) and I have it working perfectly in Gecko (tested in Firefox 1.0.6 and Deer Park Alpha 2). I'm just having some serious problems with IE and a bug in Opera. The test is supposed to get a NodeList (an Array() with an item() method...
56
3409
by: Paddy | last post by:
A work colleague circulated this interesting article about reducing software bugs by orders of magnitude: http://www.spectrum.ieee.org/WEBONLY/publicfeature/sep05/0905ext.html Some methods they talk about include removing error prone and ambiguous expressions from their ADA based language Sparc - The example they give is on why they removed the increment operators x++, x-- . A bit of googling shows that they have, in the past mentioned...
7
6548
by: wmkew | last post by:
Hello everyone I'm encountering a R6002 Runtime error and several bugs when trying to generate a simple Managed C++ application with .NET 2003. The main problem seems to arise from linking with LIBCMT(D).DLL. (My requirement is that we can't link with MSVCRT(D).LIB.) Below are steps I've followed, and the resulting problems 1. Using the New Project wizard, generate a Visual C++ .NET Class Library project (call it "Doomed") and a VC++...
9
1462
by: David Teran | last post by:
Hi, we are currently using another database product but besides some licensing issues we are finding more and more problems with the database. We are evaluating PostgreSQL and it looks quite handy. Interesting features paired with good performance and a lot of users seems to be a prove for the quality. I wonder if people encountered bugs like 'a select returns a wrong number of rows' or any other very serious bugs. We do not have...
26
350
by: ak | last post by:
Recently at an interview i was asked the following question : Assuming the function lookupName is defined, what's wrong with this code (hint: 2 bugs)? const char *getName(const char *c) { std::string name = lookupName(c); if (name == NULL) return "Anonymous";
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8337
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8531
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8628
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7359
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6181
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5650
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1978
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.