Re-building the URL with a different Host

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QWxleCBNYWdoZW4=?=

    Re-building the URL with a different Host

    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


    and I want to redirect the user automatically to whatever their current path
    is on the site, but with a different domain:


    DomainA.com and DomainB.com are actually the same server/IP, but I want to
    send the user through Response.Redire ct() 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.Redire ct("~/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]

    #2
    RE: Re-building the URL with a different Host

    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.Get LeftPart(UriPar tial.Scheme) + "DomainB" +
    Request.Applica tionPath + "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.

    Comment

    Working...