473,569 Members | 2,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transfer, Viewstate, redirect...

Hi:

I am trying to use the Transfer statement in an .aspx file
to redirect
and send Form and QueryString collections to a different
page. A good
example where this is needed is a checkout page when you
click on the
Confirm button, and the client's shopping info (items,
amount, etc.)
have to be transferred to a credit card site. There are 3
requirements
here:

1. A bunch of server operations have to happen before the
redirection,
for example reset of the shopping cart, decrementing
the inventory,
writing to the order history, etc.

2. The page form has to be converted to that required by
the credit
card company.

3. A transfer statement to send the form contents to the
credit card
site.

Ideally, all of these have to happen in a single
transaction (all or
nothing). I started by trying the following on the server:

public void Confirm_Order(O bject sender, EventArgs e)
{
ResetCart(usern ame);
AddOrder(useram e, time);
... code to create a form ...
Transfer(credit cardsite, true)
}

The shopping list was created by a Repeater control.

This seems concise, minimal and highlights the power
of .NET web forms
had it worked! Here are the problems I faced:

1. I couldn't find a way to change the contents of the
page form
(controls, values, etc.). There is no access provided
to a low
level http utility such as wininet (e.g. HINTERNET)
in .NET.

2. Once a page contains <% %> blocks, the form cannot be
changed
dynamically.

3. The overloaded Transfer method (public void Transfer
(string path,
bool preserveForm)) does not work because of the
ViewState
content. I tried clearing the ViewState, but that
didn't work
either. I like the power of ViewState, Web Form
philosophy, post
back, etc. and that all is implemented over the html
seemlessly but
it seems too hardcoded and inflexible. Considering that
the
ViewState is mainly implemented for a page at a time,
clearing it
prior to sending the control to another page should
work fine. The
only other way is to switch off ViewState in the
receiving page
(<%@ Page EnableViewState ="false"
EnableViewState Mac="false" %>
which somewhat limits the receiving page. Also, I think
there is no
point of having two methods for the same functionality.
Redirect
and (public void Transfer(string path)) are the same
(at least
that's how it looks from the documentation).

4. OK so I disabled the ViewState in the receiving page
and could use
Transfer with preserveForm=tr ue. I couldn't however
change the
clientIDs in the form (they are read onlies). Why
should this be? I
really like these server controls, but what difference
does it make
what specific html they produce as long as it all works?

At the end I had to do the following to get it to work
which is messy:

1. Re-wrote the checkout page with deleting the
runat="server" from
the form (runat="server" automatically forces the same
page to be
the action attribute of the rendered form). Put
action="gateway .aspx" where this is a page which does
all the
server actions prior to sending the the credit card
site.

2. Replaced the repeater with inline <% %> blocks to
create <input>
tags with names and values specified by the credit card
company
(the old ASP way).

3. Had to re-write other controls in the page which relied
on
runat="server" for the form to work in html.

4. Put all the server actions in Page_Load of the
gateway.aspx,
rerendered the form on this page by inlining and used
Javascript
onload to submit the form to the final page (credit
card site)
once it rendered.

This worked but was kind of disappointing. I love .NET and
its
powerful server programming functionalities but not at the
expense of
loosing control. Am I missing something?

Moheb
Nov 17 '05 #1
0 1427

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

Similar topics

3
2127
by: Manuel Lopez | last post by:
Hello, We have two applications that will reside on the same webserver. We want to be able to post from pages in App1 to to pages in App2. We need to pass sensible data, so we cannot use querystring. We are using server.transfer (needing to reference App2 in App1).
8
3778
by: Cathie | last post by:
Hi guys, I want to do a Server.Transfer to get to a second page, so that I may retrieve variables I have set in the first page. I'm doing that with the usual Server.Transfer("pagename", true). My problems are as follows: 1. On the initial load everything seems to be referencing from the first page. For example, my style sheet I...
1
3485
by: Victor Song | last post by:
Hi We are trying to stream a file using server.transfer rather than response.redirect. We have it working for IIS 5.0 but IIS 6.0 refusing to let us transfer the file. If we do the less efficient prompt/response technique to the browser both work fine. We found this article that was only slightly appicable...
1
1962
by: Mind Dragon | last post by:
I have an ASP application that works fine locally but when it's uploaded occasionally, I get viewstate errors. Another thing is that the viewstate for that page is disabled. There are cases where I can just refresh the page and it goes through ok <%@ Page Language="VB" EnableViewState="false" Debug="true" % The worker threads are set to...
2
4326
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control displaying the contents of the data source, whilst another control updates the datasource via a command buttons implementation of 'Click', an event...
3
1542
by: Ken Varn | last post by:
I have Page1 that does a transfer to page2. When the user is done with Page2, there is a button on Page2 that they can press to bring them back to Page1. I use Server.Transfer to navigate from one page to the next. The confusion that I am having is that when the user is done with Page2 and clicks on the button to bring them back to Page1,...
4
1851
by: Terry Olsen | last post by:
Since both methods seem to produce the same results, in which cases would you prefer one over the other? The only thing I would think is using Server.Transfer because of some browsers blocking redirects. *** Sent via Developersdex http://www.developersdex.com ***
11
2465
by: Nad | last post by:
Hello, I have a page with two link buttons. When I click on the first one I call server.execute("target.aspx") to view target.aspx on the original page. Then I click on the second link button and in this case I redirect to another page, HOWEVER, I get Invalid ViewState exception. I know the problem stems from server.execute but don't know...
7
267
by: dee | last post by:
Inside Search.aspx I make the following call: Server.Transfers("Table.aspx"); I'm transfered to Table.aspx and browser still shows Search.aspx in address bar. However, I do postback within Table.aspx. The first time that there is postback the address bar shows Table.aspx! Am I correct to assume that this is not the right place to use...
0
7697
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...
0
7612
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...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8120
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6283
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...
0
5219
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...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1212
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.