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

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(Object sender, EventArgs e)
{
ResetCart(username);
AddOrder(userame, time);
... code to create a form ...
Transfer(creditcardsite, 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"
EnableViewStateMac="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=true. 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 1410

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

Similar topics

3
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...
8
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). ...
1
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...
1
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...
2
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...
3
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...
4
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...
11
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...
7
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...
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
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...
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...
0
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,...
0
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...

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.