Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Retrieving Full URL from a relative url

Retrieving Full URL from a relative url

Scheduled Pinned Locked Moved ASP.NET
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dabs
    wrote on last edited by
    #1

    Hi, I have a web service that must return a URL as a return value from one of its requests. I want this URL to be full, i.e. it should include the same protocol (http or https), the same server name/port name and possibly subdirectory as the URL that was used to call this particular webservice. Basically, what I would like to achieve is for the Webservice to run code like this: String strFullUrl = RelativeUrlToFullUrl( String.Format( "~/SomeAspxPage.aspx?param1={0}", param ) ); I initially thought that Page.ResolveUrl would do that for me. However, I don't have access to a Page object within a Web Service, but apparently a System.Web.UI.WebControls.Image also contains a ResolveUrl method. Unfortunately, it only returns a URL relative to the root, but does neither contain the name of the server running the web application, nor the protocol. Is there a function somewhere in ASP.NET that will do this for me? Doing this on the client side is probably possible, but is going to be less elegant so I would prefer if the webservice could handle this completely. Regards, Daníel


    Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

    W 1 Reply Last reply
    0
    • D dabs

      Hi, I have a web service that must return a URL as a return value from one of its requests. I want this URL to be full, i.e. it should include the same protocol (http or https), the same server name/port name and possibly subdirectory as the URL that was used to call this particular webservice. Basically, what I would like to achieve is for the Webservice to run code like this: String strFullUrl = RelativeUrlToFullUrl( String.Format( "~/SomeAspxPage.aspx?param1={0}", param ) ); I initially thought that Page.ResolveUrl would do that for me. However, I don't have access to a Page object within a Web Service, but apparently a System.Web.UI.WebControls.Image also contains a ResolveUrl method. Unfortunately, it only returns a URL relative to the root, but does neither contain the name of the server running the web application, nor the protocol. Is there a function somewhere in ASP.NET that will do this for me? Doing this on the client side is probably possible, but is going to be less elegant so I would prefer if the webservice could handle this completely. Regards, Daníel


      Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

      W Offline
      W Offline
      Walter_H
      wrote on last edited by
      #2

      HttpContext.Current.Request.Url.AbsoluteUri - walter

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups