This is the method that I use in my C # application
public static string base_url() { return string.Format("{0}://{1}/", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Authority); }
Note that this returns the port also if your development server uses a different port than 80
Smith source share