473,385 Members | 1,357 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,385 software developers and data experts.

Question about ASP.NET threads: nuts & bolts

I wanted to prove a concept, so wrote a page that does the following:

public void btn_click() {
File.CreateText("file.txt");
Response.BufferOutput = false;
Response.Redirect(this.Request.FilePath, false);
Thread.Sleep(15000);
File.Delete(file.txt);
}

I expected this to cause the user's browser to be redirected to the
same page -immediately- after the user clicked a button. Indeed, this
is the behavior I observed: the browser was redirected to the same
page immediately (via HTTP 302), and another instance of the page
loaded immediately, -while- the original postback continued to run and
then, after 15 seconds, deleted the file. Everything happened
concurrently as intended.

But when I had this pattern implemented on another workstation, the
browser was redirected but a new page instance wouldn't load. In
fact, ASP.NET wouldn't respond to -any- requests for -anything- in the
website until after 15 seconds had elapsed.

Between the two test cases, the only difference seems to be how the
btn_click() handler is bound to the button's click event. In the
former case, I used AutoEventWireup. In the second case, the handler
was attached dynamically on page load.

Why does the second case cause the entire web site to hang? Why won't
ASP.NET service the request by instantiating another instance until -
after- the sleeping thread wakes up? Do handlers behave differently
(i.e. in a different thread) when attached dynamically at run-time vs.
automatically at compile-time?

--
Jeff S.

Apr 26 '07 #1
3 1560
Could be session contention. AFAIK if the same user tries to run multiple
pages at the same time, the page could be locked while waiting for access to
the session object of this user locked by the previous page ?
"Object01" <ob******@gmail.coma écrit dans le message de news:
11*********************@n15g2000prd.googlegroups.c om...
>I wanted to prove a concept, so wrote a page that does the following:

public void btn_click() {
File.CreateText("file.txt");
Response.BufferOutput = false;
Response.Redirect(this.Request.FilePath, false);
Thread.Sleep(15000);
File.Delete(file.txt);
}

I expected this to cause the user's browser to be redirected to the
same page -immediately- after the user clicked a button. Indeed, this
is the behavior I observed: the browser was redirected to the same
page immediately (via HTTP 302), and another instance of the page
loaded immediately, -while- the original postback continued to run and
then, after 15 seconds, deleted the file. Everything happened
concurrently as intended.

But when I had this pattern implemented on another workstation, the
browser was redirected but a new page instance wouldn't load. In
fact, ASP.NET wouldn't respond to -any- requests for -anything- in the
website until after 15 seconds had elapsed.

Between the two test cases, the only difference seems to be how the
btn_click() handler is bound to the button's click event. In the
former case, I used AutoEventWireup. In the second case, the handler
was attached dynamically on page load.

Why does the second case cause the entire web site to hang? Why won't
ASP.NET service the request by instantiating another instance until -
after- the sleeping thread wakes up? Do handlers behave differently
(i.e. in a different thread) when attached dynamically at run-time vs.
automatically at compile-time?

--
Jeff S.

Apr 26 '07 #2
if you call redirect and specify false for end response, only the status
code header is updated, nothing is sent to the browser (unless buffering
is turned off) until page processing is complete. if you pass true,
then a Response.End() is performed, which does a flush (sends all
buffered data) then abort.

-- bruce (sqlwork.com)

Object01 wrote:
I wanted to prove a concept, so wrote a page that does the following:

public void btn_click() {
File.CreateText("file.txt");
Response.BufferOutput = false;
Response.Redirect(this.Request.FilePath, false);
Thread.Sleep(15000);
File.Delete(file.txt);
}

I expected this to cause the user's browser to be redirected to the
same page -immediately- after the user clicked a button. Indeed, this
is the behavior I observed: the browser was redirected to the same
page immediately (via HTTP 302), and another instance of the page
loaded immediately, -while- the original postback continued to run and
then, after 15 seconds, deleted the file. Everything happened
concurrently as intended.

But when I had this pattern implemented on another workstation, the
browser was redirected but a new page instance wouldn't load. In
fact, ASP.NET wouldn't respond to -any- requests for -anything- in the
website until after 15 seconds had elapsed.

Between the two test cases, the only difference seems to be how the
btn_click() handler is bound to the button's click event. In the
former case, I used AutoEventWireup. In the second case, the handler
was attached dynamically on page load.

Why does the second case cause the entire web site to hang? Why won't
ASP.NET service the request by instantiating another instance until -
after- the sleeping thread wakes up? Do handlers behave differently
(i.e. in a different thread) when attached dynamically at run-time vs.
automatically at compile-time?

--
Jeff S.
Apr 26 '07 #3
Indeed, that's what I was counting on, and that's why I turned
buffering off in the example. And sure enough, the browser receives
that redirection code the instant the statement is executed, -
regardless- of the test case. The problem seems to involve one
scenario putting the ASP.NET request processor to sleep, while the
other doesn't.

--
Jeff S.

On Apr 26, 2:31 pm, bruce barker <nos...@nospam.comwrote:
if you call redirect and specify false for end response, only the status
code header is updated, nothing is sent to the browser (unless buffering
is turned off) until page processing is complete. if you pass true,
then a Response.End() is performed, which does a flush (sends all
buffered data) then abort.

-- bruce (sqlwork.com)

Object01 wrote:
I wanted to prove a concept, so wrote a page that does the following:
public void btn_click() {
File.CreateText("file.txt");
Response.BufferOutput = false;
Response.Redirect(this.Request.FilePath, false);
Thread.Sleep(15000);
File.Delete(file.txt);
}
I expected this to cause the user's browser to be redirected to the
same page -immediately- after the user clicked a button. Indeed, this
is the behavior I observed: the browser was redirected to the same
page immediately (via HTTP 302), and another instance of the page
loaded immediately, -while- the original postback continued to run and
then, after 15 seconds, deleted the file. Everything happened
concurrently as intended.
But when I had this pattern implemented on another workstation, the
browser was redirected but a new page instance wouldn't load. In
fact, ASP.NET wouldn't respond to -any- requests for -anything- in the
website until after 15 seconds had elapsed.
Between the two test cases, the only difference seems to be how the
btn_click() handler is bound to the button's click event. In the
former case, I used AutoEventWireup. In the second case, the handler
was attached dynamically on page load.
Why does the second case cause the entire web site to hang? Why won't
ASP.NET service the request by instantiating another instance until -
after- the sleeping thread wakes up? Do handlers behave differently
(i.e. in a different thread) when attached dynamically at run-time vs.
automatically at compile-time?
--
Jeff S.
Apr 27 '07 #4

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

Similar topics

1
by: skeeterbug | last post by:
hi all, i'm new to using php, adodb and pgsql. i have a need to enter data into a database. however, i can't find a web example or tutorial that explains the nuts and bolts of how this is...
4
by: hostmaster | last post by:
Hi, I'm quite new to Python and I am reading this book called 'Core Python Programming' by Wesley J. Chun. I think that this is not a new book but I believe some of the points are still valid....
11
by: Mark Yudkin | last post by:
The documentation is unclear (at least to me) on the permissibility of accessing DB2 (8.1.5) concurrently on and from Windows 2000 / XP / 2003, with separate transactions scope, from separate...
0
by: Kenneth Keeley | last post by:
Hi, I have been reading up on creating page templates with ASP.Net, they look like a great way to reduce the amout of repeated code. I think they would also reduce the number of errors in the...
10
by: leaf | last post by:
How do i make a simple parser that parse strings ex. "string1 string2 string3" and store in a vector? how can it be done using BOOST.Spirit? --- leaf
2
by: Eric S. Johansson | last post by:
as one would expect when creating a body of software, eventually you create a series of relatively generic components you find yourself using over and over again. As a result, I'm finding myself...
2
by: Lucy Ludmiller | last post by:
How can I write a function like this: BSTR Greeting(BSTR name) { //return "Good Morning : " + name ; } In short I'm looking for a quick tutorial on using BSTR - Google is not bringing up...
2
by: Tukumbi | last post by:
Hi I'm new to C++ and cannot seem to find a diagram that 1. Lists the files that make up the Standard C/C++ Library in terms of the ANSI standard (ISO/IEC 14882-2003) 2. Obtain the source code...
11
by: merrittr | last post by:
Hi in the code below in the main the hash table from K&R example replaces a node when a collision occurs What I am trying to do is set it up to "chain" another structure beside the node that it...
1
by: Olivier Matrot | last post by:
I have a problem with an ASP.NET 2.0 Application. A client request is processed in parrallel by two threads. After further analysis, it appears that : - There is 2 disctinct session for the...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.