Umbraco cloud and guid vs nodeid also how to redirect to page with guid
Hi,
So we deployed our umbraco website to cloud and moved all the data there using Umbraco Deploy just to find out that nodeIds are being changed when transfered. That causes some pain for us. We managed to search for content by calling UmbracoHelper.TypedContend(Guid) but we need to do something similar with redirects as our current code
RedirectToUmbracoPage(1334)
stopped working, because ids are different. As I can see the guids are the same on both ends.
So my question is - is there a way to redirect to umbraco page via Guid. If not what's the best solution for that?
var pageToRedirect = Umbraco.TypedContentSingleAtXPath("//[@key='ce0e90fc-866d-4b71-9c9d-f8be1c36fc83']");
RedirectToUmbracoPage(pageToRedirect.Id);
But are you sure you want to bind to either id or guid in that way?
Maybe you can come up with something smarter, like a content picker on a settings node, or an xpath to find the correct page. Someday one of your editors will delete that page, and then you have to update your code with a new guid.
Yes, we are hardcoding Guids for some pages that needs to be called from backend code. I've ended with something like this in the end:
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var page = umbracoHelper.TypedContent(guid);
return page.Id;
And as per second - I'm not afraid about the editors deleting the page. That's the general risk I think - if they aren't careful enough and delete the node that's marked by devs as DoNotDelete then I have no faith it will be recreated the way I want it.
Umbraco cloud and guid vs nodeid also how to redirect to page with guid
Hi,
So we deployed our umbraco website to cloud and moved all the data there using Umbraco Deploy just to find out that nodeIds are being changed when transfered. That causes some pain for us. We managed to search for content by calling
UmbracoHelper.TypedContend(Guid)
but we need to do something similar with redirects as our current codestopped working, because ids are different. As I can see the guids are the same on both ends.
So my question is - is there a way to redirect to umbraco page via Guid. If not what's the best solution for that?
Thanks Maciej
Hi Maciej
Are you hardcoding your id's?
Maybe you can fetch the id like this:
But are you sure you want to bind to either id or guid in that way?
Maybe you can come up with something smarter, like a content picker on a settings node, or an xpath to find the correct page. Someday one of your editors will delete that page, and then you have to update your code with a new guid.
Hi Søren,
Yes, we are hardcoding Guids for some pages that needs to be called from backend code. I've ended with something like this in the end:
And as per second - I'm not afraid about the editors deleting the page. That's the general risk I think - if they aren't careful enough and delete the node that's marked by devs as DoNotDelete then I have no faith it will be recreated the way I want it.
Ooh, didn't know you could put guids into .TypedContent() :)
Always a risk having editors, my advice was just so you wouldn't need a rebuild in case of deletions :)
is working on a reply...