Hello there. Within an existing non-Umbraco website, I would like to check if an Umbraco page exists (umbracoRedirectUrl table), and if so, redirect via 301 response to the page. If it doesn’t exist, deliver a non-Umbraco page within the website.
Any ideas anyone?
Before I just write a query to cache those urls and then check, I was wondering if there was some API call or Umbraco library I can use. Also, the non-Umbraco website is a old ASP.NET Webforms, and I’m running Umbraco 16. Different server machines but same database server.
The umbracoRedirectUrl table will only contain Umbraco URLs that have been redirected, not all pages will be in this table.
I’d recommend not reading the database directly as I’m not aware of any guarantee these will be the same going forwards. Have you considered using the content delivery API for this purpose? Content Delivery API | Umbraco CMS
Beware that this approach will cause all content to be eagerly loaded from the database into the cache. Depending on your cache configuration, how much content you’ve got etc. this might not be what you want. i.e. while it might not go to the database directly - you may find that the database usage from this approach works out higher overall.
You may find that combining the IDocumentUrlRepository.GetAll() method with your own caching layer, will give better, or at least more predictable performance.