Retrieving Full URL from a relative url
-
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!
-
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!