Re-building the URL with a different Host

A

Alex Maghen

I want to redirect the user to a URL that will actually be exactly the same
URL on the same site, but with a different Domain.

For example, let's say the page where the user currently resides is
http://DomainA.com/SomeFolder/Default.aspx

and I want to redirect the user automatically to whatever their current path
is on the site, but with a different domain:
http://DomainB.com/SomeFolder/Default.aspx

DomainA.com and DomainB.com are actually the same server/IP, but I want to
send the user through Response.Redirect() to that second domain.

I have no problem reading the current Host, Port, etc. from the Request.Url
object. But my problem is, let's say I want to send the user to a different
place on the site too. For example, I want them to be on a different domain
AND a to go to a path that would normally be done just be writing
Response.Redirect("~/Something/XYZ.aspx")

The problem is, I don't seem to be able to figure out how to properly BUILD
the path AND switch to a different DOMAIN into a single new URL.

Help?

Alex
 
W

Walter Wang [MSFT]

Hi Alex,

If my understanding is correct, the key issue here is how can we know the
aplication root name represented by the "~" symbol.

Please see if following code helps:

Request.Url.GetLeftPart(UriPartial.Scheme) + "DomainB" +
Request.ApplicationPath + "Something/XYZ.aspx"



Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top