If something like this works locally but not elsewhere, for me it's usually Culture & Hostnames that creates confusion in Umbraco. Sometimes it would find the wrong root node because it can't map the URL to the content tree correctly etc. Or sometimes the code is written so it
happens to work locally because there is less content, no multiple C&Hs etc. If you can, try to inspect what
.Content.Root()
actually finds in the problematic environment.