How to get the base URL of the website VB.NET

lawphotog picture lawphotog · Sep 24, 2012 · Viewed 23.5k times · Source

I may not be the first person to ask this question but I can't find what I was looking for after looking around. I want to get base URL from the URL. I have tried

    HttpContext.Current.Request.Url.AbsoluteUri

It would return me the full URL

    http://localhost:59112/Resources/VideoPlayer.aspx?ID=resources1.mp4

I would just need until here (e.g.)

    http://localhost:59112/

Thanks for your help.

Answer

lawphotog picture lawphotog · Sep 24, 2012

With a bit more research .. I got what I want from a forum .. this is brilliant solution ..

    Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath

Thanks