Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Taylor 873 posts 2086 karma points
    Feb 03, 2015 @ 23:24
    Matt Taylor
    0

    Interesting error when trying to redirect to a page that has umbracoInternalRedirectId set

    I've got the following code that finds a page using the 'Checkout' doc type and tries to redirect to it.

    var checkoutPage = CurrentPage.Website().Descendants("Checkout").First();

    if (checkoutPage != null)
    {
        return RedirectToUmbracoPage(checkoutPage);
    }

    It executes HomeUrlProvider.GetUrl which errors on the following line

    var content = umbracoContext.ContentCache.GetById(id);

    with:

    {"Invalid attempt to call MetaData when reader is closed."}

    and I'm thinking it's because umbracoInternalRedirectId is set on the Checkout page.

    Most of the properties can be access on the checkoutPage i.e. Name, Id etc. but if you attempt to read the Url is will also cause the same error.

    I had expected Umbraco to just redirect to the page that the Checkout page is redirecting to.

  • Matt Taylor 873 posts 2086 karma points
    Feb 03, 2015 @ 23:38
    Matt Taylor
    0

    If I use the alias umbracoRedirect instead of umbracoInternalRedirectIdon the Checkout page it work fine.

    In my case that's good because it's more what I want anyway but perhaps the error should be fixed anyway?

    Regards, Matt

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 04, 2015 @ 09:05
    Jeroen Breuer
    0

    Hello,

    The internal redirect should be set to the homepage because that will get the url of it's parent. I haven't tested it if you set the internal redirect to a different page, but I can imagine that it might go wrong.

    Jeroen

  • Matt Taylor 873 posts 2086 karma points
    Feb 04, 2015 @ 10:53
    Matt Taylor
    0

    Maybe I did not explain it properly.

    With umbracoInternalRedirectId being an Umbraco reserved alias for redirecting to the chosen page without changing the url I think you should ideally be able to use it on any node to redirect to any other throughout the site without the error.

    Cheers, Matt

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 04, 2015 @ 10:57
    Jeroen Breuer
    0

    Yes that should be possible, but for the Hybrid Framework the umbracoInternalRedirectId on the website node should go to the homepage. I don't know what happens if you point to another node because the HomeUrlProvider might conflict with that. Maybe you need to remove the the HomeUrlProvider in that case.

    Jeroen

  • Matt Taylor 873 posts 2086 karma points
    Feb 04, 2015 @ 11:02
    Matt Taylor
    0

    Ah yes, the hompegape, that's fine.

    In this situation umbracoInternalRedirectId is used on another node 'Checkout' and set to point to its first child.

    When I go to the 'Checkout' page it doesn't redirect to its first child like it should, it just gives the error.

    Matt

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 04, 2015 @ 11:10
    Jeroen Breuer
    0

    Ok so when you use the umbracoInternalRedirectId on another page you get the error on the HomeUrlProvider? That's strange because the HomeUrlProvider is execute before the DefaultUrlProvider so nothing should be closed yet as in the error. 

    Maybe RedirectToUmbracoPage just doesn't work when you redirect to a page that has an umbracoInternalRedirectId. What happens if you do a normal Redirect?

    Jeroen

  • Matt Taylor 873 posts 2086 karma points
    Feb 04, 2015 @ 11:49
    Matt Taylor
    0

    If I use 'umbracoRedirect' instead it works.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 04, 2015 @ 11:52
    Jeroen Breuer
    0

    umbracoRedirect does something very different. That's just a normal redirect which also changes the url. With umbracoInternalRedirectId the url won't change.

    Jeroen

  • Matt Taylor 873 posts 2086 karma points
    Feb 04, 2015 @ 12:06
    Matt Taylor
    0

    OK, if I'm using umbracoInternalRedirectId and I hardcode the url with:

    Response.Redirect("http://www.mysite.local/checkout/");

    then it works fine.

    What I cannot do is

    var checkoutPage = CurrentPage.WebsiteLanguage().Descendants("Checkout").First();
    Response.Redirect(checkoutPage.Url);

    because the call to checkoutPage.Url will return the error.

    Regards, Matt

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Feb 04, 2015 @ 12:14
    Jeroen Breuer
    0

    Ok thanks for the info. When you call .Url the HomeUrlProvider is called, but I still don't know why that wouldn't work.

    Jeroen

  • Matt Taylor 873 posts 2086 karma points
    Feb 04, 2015 @ 12:17
    Matt Taylor
    0

    No worries, I just wanted to flag it for the future.

  • Stephen 767 posts 2273 karma points c-trib
    Feb 04, 2015 @ 12:20
    Stephen
    0

    if

    var checkoutPage =CurrentPage.WebsiteLanguage().Descendants("Checkout").First();
    Response.Redirect(checkoutPage.Url);

    does produce the error - can I have the stacktrace of that error?

    I don't get what's so special about that checkout page that .Url fails, and I cannot find out where {"Invalid attempt to call MetaData when reader is closed."} comes from.

    Stephan

  • Matt Taylor 873 posts 2086 karma points
    Feb 04, 2015 @ 14:26
    Matt Taylor
    100

    Ummm, it's fixed itself or I can no longer reproduce it. :-S

    I closed down my project and opened a clean HybridFrameworkExamples project I had to see if I could reproduced it there.
    I couldn't so I fugured it mught be because my project has been upgraded to 7.2, whereas the HybridFramework project is 7.1.

    Reloaded my project and tried to reproduce the problem to get the stacktrace you asked for and it's no longer a problem.

    I'm assuming something had its knickers in a twist.

Please Sign in or register to post replies

Write your reply to:

Draft