Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Professionals
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Professionals If you are an experienced ASP.NET programmer, this is the forum for your 3.5 questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 5th, 2010, 06:51 PM
Friend of Wrox
Join Date: Dec 2008
Location: , , .
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default How to use PostBackUrl in pages that currently rely on Response.Redirect (heavily)?

I am changing some existing ASP.Net pages. Those pages heavily rely on Response.Redirect. Now I need to carry data between pages, and one obvious option is to change each Response.Redirect to Server.Transfer. This way the modification is very straightforward. However the problem is that Server.Transfer does not change the URL in the address bar, which some see as a problem.

The other option is to rely on PostBackUrl, but the modification seems to be extensive in some cases. For example, say I have two pages P1 and P2, both lead to page P3. P1 has a button B1. In the existing code, when B1 is clicked, it executes a chunk of code (C1) and in the end of C1, it does Response.Redirect. Same with P2, which has a button B2 and only calls Response.Redirect after a major chunk of code (C2) is executed.

Now, if I set PostBackUrl for both B1 and B2 to P3. Where is the best new home for C1 and C2 to reside?
  #2 (permalink)  
Old May 5th, 2010, 09:39 PM
Lee Dumond's Avatar
Wrox Author
Points: 4,942, Level: 29
Points: 4,942, Level: 29 Points: 4,942, Level: 29 Points: 4,942, Level: 29
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2008
Location: Decatur, IL, USA.
Posts: 923
Thanks: 12
Thanked 166 Times in 162 Posts

If I follow you, I would say the place to put C1 and C2 is in the code-behind of P3. Them in the OnLoad of P3, you can detect the PreviousPageUrl and run whatever chunk of code you want based on that.
Visit my blog at http://leedumond.com
Follow me on Twitter: http://twitter.com/LeeDumond

if (this.PostHelpedYou)
  #3 (permalink)  
Old May 5th, 2010, 10:44 PM
Friend of Wrox
Join Date: Dec 2008
Location: , , .
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts

Thanks for your reply!

I thought the same way and that's what I feared - this way, code is a bit messier than what I would like...

Another obvious option is to carry the data as URL parameters. The data I want to carry are of simple scalar types and there are only couple of them, so there is not much trouble to do it this way. The pros are:
1) The code change is very small, and I don't even need to touch those Response.Redirect;
2) Obviously URL's are all correct (since I am not using Server.Transfer)

I initially didn't like this query string solution, since it exposes more information than necessary (and in a obvious way). However that piece of information is not sensitive any way.

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
response.redirect sarah lee ASP.NET 1.0 and 1.1 Basics 1 October 27th, 2006 08:57 AM
response.redirect ava_h .NET Framework 2.0 0 October 18th, 2006 10:21 PM
response.redirect crmpicco Classic ASP Basics 3 February 9th, 2005 01:50 AM
What is an alternative for Response.Redirect pcshan Classic ASP Basics 3 April 28th, 2004 02:10 PM
Response.Redirect dhborchardt Classic ASP Basics 4 June 16th, 2003 05:56 AM

All times are GMT -4. The time now is 02:51 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.