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.
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.
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.
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?
umbracoRedirect does something very different. That's just a normal redirect which also changes the url. With umbracoInternalRedirectId the url won't change.
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.
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.
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.
It executes HomeUrlProvider.GetUrl which errors on the following line
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.
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
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
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
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
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
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
If I use 'umbracoRedirect' instead it works.
umbracoRedirect does something very different. That's just a normal redirect which also changes the url. With umbracoInternalRedirectId the url won't change.
Jeroen
OK, if I'm using umbracoInternalRedirectId and I hardcode the url with:
then it works fine.
What I cannot do is
because the call to checkoutPage.Url will return the error.
Regards, Matt
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
No worries, I just wanted to flag it for the future.
if
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
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.
is working on a reply...