Can anyone point me to a simple way of reading Querystring values from within a View in Umbraco v9?
Apologies if this is more of an ASP.NET Core type of question... I'm just getting up to speed and it appears Request.Querystring isn't available to me anymore!
As you say this is more of a "how it is in .NET Core" rather than Umbraco related - the main change really being that you need to inject the service responsible for accessing the HttpContext into the view.
Accessing Query String from a View
Hello,
Can anyone point me to a simple way of reading Querystring values from within a View in Umbraco v9?
Apologies if this is more of an ASP.NET Core type of question... I'm just getting up to speed and it appears Request.Querystring isn't available to me anymore!
Thanks,
- Chris
Yes, to read querystring values in the view, you can do this:
As you say this is more of a "how it is in .NET Core" rather than Umbraco related - the main change really being that you need to inject the service responsible for accessing the HttpContext into the view.
Andy
Thanks - I had a feeling it wasn't really Umbraco specific, but really appreciate the answer anyway! 😁
Is there a way to get all the parameters after the "?"
I believe you can get all by changing Query[key] from Andy's answer into QueryString :
HttpContextAccessor.HttpContext.Request.QueryString
is working on a reply...