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

Server.Transfer or Server.Execute vs WebClient

Hi,

This may sound a little complicated, but here goes:

I have 2 webforms (lets call them 'x' and 'y').

* - 'x' is a form which contains a single server side TextBox web
control, and an iframe.
The iframe's src attribute references the 'y' webform.

* - The 'y' webform has a server side button, and a textbox of the
exact same name as 'x's textbox.

Now here comes the hard part (to explain / understand):
When clicking the 'y's button, 3 things happen:
1. On the client-side, I copy 'x's textbox value to 'y's textbox.
2. 'y' posts back to the server.
3. 'y's button_click event handler creates a WebClient and performs
UploadValues with the TextBox's value (using post method).

This works great, and believe it or not, the new 'x' instance now has a
TextBox control with the correct value at its Text property.

However, if I change the WebClient to a Server.Transfer (or
Server.Execute for that matter - same thing), 'x's textbox contains
nothing on the server side.

When I activated the Trace, I saw that the WebClient's trace went
through the entire ProcessRequest of the Page, where as the
Server.Transfer's trace stopped right after "Begin Load" (probably at
the LoadRecursive function.

I was wondering if anyone has an idea, why the difference between the
two.

Thanks.

Feb 12 '06 #1
4 2282
Server.Transfer is designed to cease execution and directly transfer to the
specified URL

--
Terry Burns
http://TrainingOn.net

"ewolfman" <ew******@yahoo.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.com...
Hi,

This may sound a little complicated, but here goes:

I have 2 webforms (lets call them 'x' and 'y').

* - 'x' is a form which contains a single server side TextBox web
control, and an iframe.
The iframe's src attribute references the 'y' webform.

* - The 'y' webform has a server side button, and a textbox of the
exact same name as 'x's textbox.

Now here comes the hard part (to explain / understand):
When clicking the 'y's button, 3 things happen:
1. On the client-side, I copy 'x's textbox value to 'y's textbox.
2. 'y' posts back to the server.
3. 'y's button_click event handler creates a WebClient and performs
UploadValues with the TextBox's value (using post method).

This works great, and believe it or not, the new 'x' instance now has a
TextBox control with the correct value at its Text property.

However, if I change the WebClient to a Server.Transfer (or
Server.Execute for that matter - same thing), 'x's textbox contains
nothing on the server side.

When I activated the Trace, I saw that the WebClient's trace went
through the entire ProcessRequest of the Page, where as the
Server.Transfer's trace stopped right after "Begin Load" (probably at
the LoadRecursive function.

I was wondering if anyone has an idea, why the difference between the
two.

Thanks.

Feb 12 '06 #2
Hi Terry,

As I've written, Server.Transfer or Server.Execute - it doesn't matter.
Server.Transfer calls Server.Execute, but simply doesn't return the
control's execution.

So this isn't the answer.

However, I did manage to find the problem. The loading process of the
Page determines on how to load the page, using the IsPostback property.
The IsPostback property for a Server.Transfer returns false (in
contrast to the WebClient.UploadValues), because the context's handler
isn't the same as the target page, and the ServerExecuteDepth is
greater than 0 (in contrast to the WebClient effect).

Therefore - the following 2 lines (before calling the Server.Transfer)
- seem to have solved the problem:

type = Type.GetType("ASP.default_aspx");
HttpContext.Current.Handler =
(IHttpHandler)Activator.CreateInstance(type);

Thanks anyway.

Feb 12 '06 #3
Did you try this with the additional attribute which preserves the context
and form variables on transfer ?

--
Terry Burns
http://TrainingOn.net
"ewolfman" <ew******@yahoo.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi Terry,

As I've written, Server.Transfer or Server.Execute - it doesn't matter.
Server.Transfer calls Server.Execute, but simply doesn't return the
control's execution.

So this isn't the answer.

However, I did manage to find the problem. The loading process of the
Page determines on how to load the page, using the IsPostback property.
The IsPostback property for a Server.Transfer returns false (in
contrast to the WebClient.UploadValues), because the context's handler
isn't the same as the target page, and the ServerExecuteDepth is
greater than 0 (in contrast to the WebClient effect).

Therefore - the following 2 lines (before calling the Server.Transfer)
- seem to have solved the problem:

type = Type.GetType("ASP.default_aspx");
HttpContext.Current.Handler =
(IHttpHandler)Activator.CreateInstance(type);

Thanks anyway.

Feb 12 '06 #4
if you refer to the 'preserveForm', then the answer is yes (i.e. it is
set to true).

Feb 13 '06 #5

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

Similar topics

1
by: JT | last post by:
i'm using a model, view, control architecture for a group of .asp pages. i can't decide whether to use Server.Transfer or Server.Execute to pass posted data from my control to my model. are...
0
by: Srini | last post by:
I am implementing Front Controller in ASP.net as outlined in Microsoft documentation titled "Implementing Front Controller in ASP.NET Using HTTPHandler"...
5
by: Paul de Goede | last post by:
I set the Response.Filter in my aspnet application but I have noticed that if you do a Server.Transfer that the filter doesn't get called. And in actual fact the response is mostly empty. It seems...
9
by: Mark | last post by:
Hello I'm trying to use a Server.Transfer in a try-catch (I cannot put it outside the Try-Catch as it is nested deep within a component that is called in a try-catch loop) The problem is that the...
5
by: Guadala Harry | last post by:
I've been reading up on Server.Transfer as well as doing some testing, and it appears to always raise the ThreadAbortException error. On one hand I've read a bunch of promotional-type material...
18
by: UJ | last post by:
Folks, We provide custom content for our customers. Currently we put the files on our server and people have a program we provide that will download the files. These files are usually SWF, HTML or...
5
by: Richard | last post by:
I've developed a small ASPX template framework (based on Chun Li's article on CodeProject: http://www.codeproject.com/aspnet/headerfooter.asp#xx849313xx) which uses a IHttpModule to apply...
3
by: David Veeneman | last post by:
I am creating a form on the server that I want to POST to a URL that's being called with Server.Transfer(). What's the simplest way to do that? A little background: I'm programming buttons that...
9
by: RN1 | last post by:
When a server encounters the line Response.Redirect("abcd.asp") in a ASP script, the server tells the browser that it has to be redirected to another page (which is abcd.asp, in this case)....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.