Source code location: ./master_pages/masterpagebase.cs
using System.Web.UI; using System.Web; namespace MyProject.MasterPages { public class MasterPageBase : MasterPage { protected string BaseURL { get { try { return string.Format("http://{0}{1}", HttpContext.Current.Request.ServerVariables["HTTP_HOST"], (VirtualFolder.Equals("/")) ? string.Empty : VirtualFolder); } catch { // This is for design time return null; } } } /// <summary> /// Returns the name of the virtual folder where our project lives /// </summary> private static string VirtualFolder { get { return HttpContext.Current.Request.ApplicationPath; } } } }
Copyright © 2004-2006, Milan Negovan. All rights reserved. | License
Back to AspNetResources.com