I think you can access that data inside the SharePoint page context. I got mine working in JS/React. Got the idea from here. Its in JS but you might be able to get it somehow in c# using the same concept.