Pass an additionnal HTTP parameter while using Server.Transfer

J

Julien C.

Hi all,

I have an "EditeItem.aspx" page which lets me edit properties of an "Item".
In the OnClick() event of my Save button, I do save Item changes to the
database and then I redirect the user to the Item page "ViewItem.aspx" with
a simple :

Server.Transfer("ViewItem.aspx");

I'd like to pass another HTTP parameter so that in the "ViewItem.aspx" page,
I am able to know that the user comes from the "EditItem.aspx". Here's what
I'd like to do :

Request.QueryString.Add("RefreshMenu", "1"); // <-- Raises an
exception
Server.Transfer("ViewItem.aspx");

Indeed, QueryString (or Form, or Params) are read-only collection and
therefore, it raises an exception. How can I pass an addtionnal HTTP
parameter ?

Thanks in advance !

Julien C.
 
S

Seb

Hi Julien,

Server.Transfer("ViewItem.aspx?source=EditItem.aspx");

Cheers
Seb
-----Original Message-----
Hi all,

I have an "EditeItem.aspx" page which lets me edit properties of an "Item".
In the OnClick() event of my Save button, I do save Item changes to the
database and then I redirect the user to the Item page "ViewItem.aspx" with
a simple :

Server.Transfer("ViewItem.aspx");

I'd like to pass another HTTP parameter so that in the "ViewItem.aspx" page,
I am able to know that the user comes from
the "EditItem.aspx". Here's what
 
G

Guest

Should work!

How do you read the parameter?
string source = Request.Params["source"];

If not ok:
try
Response.Redirect(url);
instead of
Server.Transfer(url);


Seb
 
J

Julien C.

Yep,

I read the parameter with : string source = Request.Params["source"];

I don't want to use Response.Redirect() since it involves another roundtrip.
The interest of Server.Transfer() was that it happens entirely on the
server.

I'd really like to do this using Server.Transfer()

Julien C.

<[email protected]> a écrit dans le message de
Should work!

How do you read the parameter?
string source = Request.Params["source"];

If not ok:
try
Response.Redirect(url);
instead of
Server.Transfer(url);


Seb
 
P

Patrice Scribe

You could use a session variable.

In this particular case, I would still use Response.Redirect as you want to
say to the browser to point to another location (with Server.Transfer the
browser will still show the "old" URL).

IMO, Server.Transfer is rather for those who have processing only pages. It
allows then to transfer the control to a processing only page easily server
side, before perhaps a final redirect to let the browser point to anotehr
final web page (rather than to have several redirects).

Patrice

--

Julien C. said:
Yep,

I read the parameter with : string source = Request.Params["source"];

I don't want to use Response.Redirect() since it involves another roundtrip.
The interest of Server.Transfer() was that it happens entirely on the
server.

I'd really like to do this using Server.Transfer()

Julien C.

<[email protected]> a écrit dans le message de
Should work!

How do you read the parameter?
string source = Request.Params["source"];

If not ok:
try
Response.Redirect(url);
instead of
Server.Transfer(url);


Seb
-----Original Message-----
Hi Seb,

I already tried and it doesn't work !
Thanks anyway !

Julien C.

"Seb" <[email protected]> a écrit dans le message de



.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top