How to determine the pat of the current web site

Posted by Velika2 on Stack Overflow See other posts from Stack Overflow or by Velika2
Published on 2010-05-11T12:11:35Z Indexed on 2010/05/11 12:14 UTC
Read the original article Hit count: 305

Filed under:

I wanted to create a function which would return the path of the current web site. This is what I thought was working while running in the IDE:

 Public Shared Function WebsiteAbsoluteBaseUrl() As String

            Dim RequestObject As System.Web.HttpRequest = HttpContext.Current.Request

            Return "http://" & RequestObject.Url.Host & ":" & _
                               RequestObject.Url.Port & "/" & _
                               RequestObject.Url.Segments(1)
        End Function

Does this seem like it should work? Is there a more straight forward way?

© Stack Overflow or respective owner

Related posts about ASP.NET