Query string to node id

Hi,

I am using the following code to get a query string from the address bar..

var eventid = HttpContextAccessor.HttpContext.Request.Query["event"];

I am then trying to use the result to get page content…

var page = UmbracoContext.Content.GetById(eventid);

But it seems as though it doesn’t like the fact that eventid is a string and I cannot seem to convert the string to an integer whatever I try.

Any ideas would be greatly appreciated.

I am using Umbraco 12

Thanks


This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/113039-query-string-to-node-id