Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Chris Roberts 6 posts 88 karma points
    Aug 11, 2021 @ 22:46
    Chris Roberts

    Accessing Query String from a View


    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!

    - Chris

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Aug 12, 2021 @ 05:18
    Andy Butland

    Yes, to read querystring values in the view, you can do this:

    @inject Microsoft.AspNetCore.Http.IHttpContextAccessor HttpContextAccessor
        var testValue = HttpContextAccessor.HttpContext.Request.Query["test"];
        <div>Value: @testValue</div>

    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.


  • Chris Roberts 6 posts 88 karma points
    Aug 12, 2021 @ 06:11
    Chris Roberts

    Thanks - I had a feeling it wasn't really Umbraco specific, but really appreciate the answer anyway! 😁

  • Yaco Zaragoza 80 posts 334 karma points
    Aug 25, 2023 @ 14:25
    Yaco Zaragoza

    Is there a way to get all the parameters after the "?"

  • Fiona 16 posts 197 karma points
    Aug 29, 2023 @ 12:36

    I believe you can get all by changing Query[key] from Andy's answer into QueryString :


Please Sign in or register to post replies

Write your reply to: