1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Bugs & Issues / Embedded Resource Issues on Staging

Embedded Resource Issues on Staging

2 posts, 0 answered
  1. Pavliks
    Pavliks avatar
    68 posts
    Registered:
    06 Apr 2010
    11 May 2011
    Link to this post
    Hi,

    We've migrated all of our references to embedded resources in our custom controls to the new format using the VPP, we added the code to the global.asax file and got everything up and running in development.
     
    Global.asax code
    protected void Application_Start(object sender, EventArgs e)
            {
                Telerik.Sitefinity.Abstractions.Bootstrapper.Initialized += new EventHandler<Telerik.Sitefinity.Data.ExecutedEventArgs>(Bootstrapper_Initialized);
            }
      
            protected void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs args)
            {
                if (args.CommandName == "RegisterRoutes")
                {
                    var virtualPathConfig = Config.Get<VirtualPathSettingsConfig>();
      
                    var blahUIVirtualPathConfig = new VirtualPathElement(virtualPathConfig.VirtualPaths)
                    {
                        VirtualPath = "~/blah/*",
                        ResolverName = "EmbeddedResourceResolver",
                        ResourceLocation = "Blah.Sitefinity.UI"
                    };
                    virtualPathConfig.VirtualPaths.Add(blahUIVirtualPathConfig);
                }
            }

    Our embedded images work in our controls and are returned if I call them directly using something like the following:

    http://localhost:57300/blah/Blah.Sitefinity.UI.TweetList.Resources.Images.logo.jpg

    The problem is when we move this code to our staging server our embedded images no longer show up and I can't hit them directly.

    Some things I already checked for include the following:
    -The images are marked as embedded resources
    -I checked the assemblyinfo.cs file to be sure that the resource is there

    Any suggestions?

    Thanks,
    Steve
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 May 2011
    Link to this post
    Hi SteveW,

    We have sent a response in the support ticket you have opened. For convenience, here is our response:

    Yes it is possible to reference images from embedded locations. However you have to always call the ~/SfRes virtual path (not yours) in order to get the provider to serve the images. You have to follow the bellow convention

    1) Set the images as embedded resources / it is not necessary to set them as embedded resources.
    2) When constructing the virtual path you should follow the following convention ~/SfRes/images/AssemblyName/Path. For example if your assembly is called Sitefinity.Samples and inside you have a folder called Images here is how the path should look like:

    Copy Code
    <asp:Image runat="server" ID="image1" ImageUrl="~/SFRes/images/Sitefinity.Samples/Images.DefaultPhoto.png" />

    3) You can use the RouteHelper.ResolveUrl static method in order to resolve urls to application relative paths, rooted paths, absolute paths, etc.

    Best wishes,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
2 posts, 0 answered