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

Forums / Bugs & Issues / Viewing or editing page gives "is not a valid virtual path." error

Viewing or editing page gives "is not a valid virtual path." error

5 posts, 0 answered
  1. Vaughn
    Vaughn avatar
    8 posts
    Registered:
    21 Oct 2010
    22 Oct 2010
    Link to this post
    Hello

    I had a page that was working previously, but now fails to render. It is possible that this was caused by upgrading to SP4, as it worked previously to that.

    I can't edit the page because it also fails on the admin side. So I'm kind of stuck on how to resolve it.

    Exception Details: System.Web.HttpException: '/Images/explore/usa-map-868.jpg#TB_inline?KeepThis=true&TB_iframe=true&width=898&height=681' is not a valid virtual path.

    The path referred to passed parameters to a Thickbox modal window.

    Here is the stack trace:
    [HttpException (0x80004005): '/Images/explore/usa-map-868.jpg#TB_inline?KeepThis=true&TB_iframe=true&width=898&height=681' is not a valid virtual path.]
       System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options) +8855707
       System.Web.VirtualPathUtility.ToAppRelative(String virtualPath) +12
       Telerik.Cms.Web.LinkParser.Resolve(HtmlChunk chunk, Int32 valueIndex, GetItemUrl itemUrl, ResolveUrl resolveUrl, Boolean preserveOriginalValue, Boolean resolveAbsolute) +1140
       Telerik.Cms.Web.LinkParser.ParseHtml(String html, GetItemUrl itemUrl, ResolveUrl resolveUrl, Boolean resolve, Boolean preserveOriginalValue, Boolean resolveAbsolute) +246
       Telerik.Cms.Web.LinkParser.ResolveLinks(String html, GetItemUrl itemUrl, ResolveUrl resolveUrl, Boolean preserveOriginalValue, Boolean resolveAsAbsoluteUrl) +23
       Telerik.Cms.Engine.WebControls.GenericContent.Render(HtmlTextWriter writer) +396
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
       System.Web.UI.Control.Render(HtmlTextWriter writer) +10
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
       System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +163
       System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
       System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +51
       System.Web.UI.Adapters.ControlAdapter.Render(HtmlTextWriter writer) +21
       Telerik.Cms.Web.FormAdapter.Render(HtmlTextWriter writer) +142
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +8681849
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
       System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +40
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
       System.Web.UI.Control.Render(HtmlTextWriter writer) +10
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
       System.Web.UI.Page.Render(HtmlTextWriter writer) +29
       Telerik.Web.UI.RadAjaxPage.Render(HtmlTextWriter writer) +43
       Telerik.Cms.Web.InternalPage.Render(HtmlTextWriter writer) +482
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266

    What is causing this, and how do I resolve it? 



  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    24 Oct 2010
    Link to this post
    Hello Vaughn,

    You have added a link inside GenricContent control that cannot be resolved properly, Your href tag should looks as shown in the code snippet below

    href="~/Images/explore/usa-map-868.jpg#TB_inline?KeepThis=true&TB_iframe=true&width=898&height=681"


    You can easily see that you are using a not correct string by using the following generic ASP.NET code in a user control

    var val = "/Images/explore/usa-map-868.jpg#TB_inline?KeepThis=true&TB_iframe=true&width=898&height=681";
    val = VirtualPathUtility.ToAppRelative(val);

    You can rollback the page and edit GenericContent control or use RemoveControl method of IStagedPage to remove the control programatically.

    sample

    ICmsPage p = (ICmsPage)Manager.GetPage(cmsPage.ID, true);
    IStagedPage staged = p.Staged as IStagedPage;
    foreach (ICmsWebControl c in staged.Controls)
    {
        if (c.ControlType == typeof(Telerik.Cms.Engine.WebControls.GenericContent))
        {
            staged.RemoveControl(c);
            p = (ICmsPage)Manager.GetPage(p.ID, true);
            p.Publish();
            Manager.SavePage(p);
     
            break;
     
        }


    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Matt
    Matt avatar
    14 posts
    Registered:
    25 Jan 2012
    27 Apr 2012
    Link to this post
    Hey Ivan,

    Sorry to resurrect this old thread but this is the exact problem I am having.  I've inherited a site that was built on 3.2 and we are going to migrate to 5.0, but we must first upgrade to 3.7SP4.  I've got 3.7SP4 almost completely working, except I'm getting this "XXXXX is not a valid virtual path" error quite a bit due to many pieces of generic content having "/xxxxx/xxxx.aspx" style links. 

    I understand the solution you've posted Ivan, but if that is the only way to fix this then I might be in a lot of trouble as this site has over 1400 pages and it would take me a lifetime to identify everywhere this is occurring and then update these links.

    Can you offer any suggestions? Thank you!

    matt
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    30 Apr 2012
    Link to this post
    Hello,

    You can query the database and get the ContentBlock controls from there. Then apply some reg ex expression or some condition over the content that is set in your generic content controls and later change them through UI or using the database query. To get all generic content controls you need to execute the query shown below

    SELECT *
    FROM [sf_WebControlBase] WHERE Type LIKE 'Telerik.Cms.Engine.WebControls.GenericContent, Telerik.Cms.Engine%'

    Then you need to join with [sf_CmsCtrlLinks] to get the relation PageID - ControlID.

    Finally you have to query [sf_PageBase] to get the page name.

    To get the GenericContent control content directly you have to query [sf_CmsTextContent] if this is a shared content. If not, then the content is just a property of GenericContent and you need to query [sf_CmsControlProperty] WHERE  Name = 'Content'  AND ControlID='your control ID'




    Greetings,
    Ivan Dimitrov
    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
  5. Matt
    Matt avatar
    14 posts
    Registered:
    25 Jan 2012
    30 Apr 2012
    Link to this post
    Ivan,

    Thank you for the guidance! I ran the following two SQL statements on our database to update the non-shared Generic Content:

    UPDATE sf_CmsControlProperty
        set Value = replace(Value, 'src="/', 'src="~/')
        WHERE Name = 'Content'
     
    UPDATE sf_CmsControlProperty
        set Value = replace(Value, 'href="/', 'href="~/')
        WHERE Name = 'Content'

    And to update the shared Generic Content on the site executed the following code:

    //get all content
    ContentManager manager = new ContentManager();
    IList contents = manager.GetContent();
     
    //modify each content to remove the offending link style if necessary
    foreach (IContent content in contents)
    {
        IContent editContent = manager.GetContent(content.ID);
     
        //remove all src="/xxxxx/xxxx" style links, relative from root must be ~/ as of 3.7 or it crashes the page it lives on (this only affects shared content)
        String sContent = editContent.Content.ToString();
        sContent = sContent.Replace(@"src=""/", @"src=""~/");
        sContent = sContent.Replace("src='/", "src='~/");
        sContent = sContent.Replace(@"href=""/", @"href=""~/");
        sContent = sContent.Replace("href='/", "href='~/");
        editContent.Content = sContent;
     
        //save the new content
        manager.SaveContent(editContent, ContentStatus.Published);
    }

    It appears to gotten everything. Thanks again.

    matt
Register for webinar
5 posts, 0 answered