Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

Re-building the URL with a different Host

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alex Maghen - 16 Feb 2008 15:50 GMT
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
Walter Wang [MSFT] - 18 Feb 2008 01:48 GMT
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 (wawang@online.microsoft.com, 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.