Image path

Discussion in 'ASP.NET / ASP.NET Core' started by nationalopi, May 15, 2010.

  1. In my MVC application I am using extension methods to resolve a path to my images and photos. The ContentRoot resolves the root folder for all content (css, scripts, images, photos, etc).

    Code:
        public static string ContentRoot
        {
            get
            {
                string contentVirtualRoot = "~/Content";
                
                return VirtualPathUtility.ToAbsolute(contentVirtualRoot);
            }
        }
    
    and the PhotoRoot resolves the folder for all photos
    Code:
        public static string PhotoRoot
        {
            get { return string.Format("{0}/{1}", ContentRoot, "Photos"); }
        }
    
    This works locally, but after upload to DASP, the path to the photo is resolved by appending the photo path to the url path for the aspx page that is rendered (ex "http://www.myWebSite.com/members/Content/Photos/photo1.jpg").

    I need to get rid of the members part of the url.

    Any help is appreciated

    Jim
     

Share This Page