Redirect Options

G

Guadala Harry

I need to add logic to the Page_Load event behind a site's default.aspx;
that will allow either default.aspx to load - OR load a completely different
page instead of default.aspx. The other pages to possibly load exist within
that site. The site owner says he wants to be able to specify any of his
existing pages as the site's default - and to change it whenever he wants.
So I'm adding a table to the db which will hold the site's "current
default.aspx". The Page_Load logic behind default.aspx will look to that
table to determine if it should continue to load itself or instead send a
different page altogether down to the browser.

I'd appreciate some advice on which of the redirection options I should use.
As I see it, here are the possibilities:
1. Response.Redirect
2. Server.Transfer
3. HttpContext.RewritePath
4. Server.Execute
? other possibilities?

So, if you had this requirement, how would you go about implementing it?
Thoughts? Rationalle?

Thanks!
 
S

Scott Allen

I'd probably lean towards using RewritePath in an HttpModule with a
Begin_Request event handler. This would keep the logic of selecting
which page to execute outside of the page execution.

The drawbacks here are that you'll need to RewritePath a second time
to get the correct Action tags on any pages that POST back, and use
ResolveUrl to link to images in some scenarios. If this causes too
many problems, Server.Transfer might be easier imlementation wise.

I'd probably shy away from Response.Redirect, not just because it
involves a round trip, but because the users will get the URL to the
"other" default page and might just bookmark it, meaning all the logic
and table setup will go to waste. Server.Execute could present the
same problems with POST backs as mentioned earlier.
 
G

Guadala Harry

Hi Scott,
<<you'll need to RewritePath a second time to get the correct Action tags on
any pages that POST back>>

All of the pages that could be redirected to do in fact POST back... So,
given that fact, can it be an easy conclusion that I should just go with
Server.Transfer in order to have the "cleanest" implementation?

-GH
 
S

Scott Allen

That would be pretty clean, but I'd do a little prototyping to make
sure nothing odd happens for the exact architecture you are using.
 

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

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,174
Latest member
BlissKetoACV
Top