locked
how do ResolveUrl Method works RRS feed

  • Question

  • User-64607594 posted

     what is ResolveUrl Method   and  what are its benefits

    Monday, July 2, 2007 3:39 AM

Answers

  • User1218727321 posted
    Hi,

    If the relativeUrl parameter contains an absolute URL, the URL is returned unchanged. If the relativeUrl parameter contains a relative URL, that URL is changed to a relative URL that is correct for the current request path, so that the browser can resolve the URL.

    For example, consider the following scenario:

    • A client has requested an ASP.NET page that contains a user control that has an image associated with it.

    • The ASP.NET page is located at /Store/page1.aspx.

    • The user control is located at /Store/UserControls/UC1.ascx.

    • The image file is located at /UserControls/Images/Image1.jpg.

    If the user control passes the relative path to the image (that is, /Store/UserControls/Images/Image1.jpg) to the ResolveUrl method, the method will return the value /Images/Image1.jpg.

    This method uses the TemplateSourceDirectory property to resolve to the absolute URL. The returned URL is for client use.

    Regards,

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, July 2, 2007 4:04 AM