Copied to clipboard

Flag this post as spam?

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

  • Daniel Hursan 4 posts 64 karma points
    Jan 25, 2024 @ 16:56
    Daniel Hursan

    Parameters posting back correctly, locally (macOS) but not on Umbraco Cloud (Windows, same code)


    I created a component which works correctly on my machine (MacOS), but when I deploy code to Umbraco Cloud, parameters are all empty

    This next part works correctly, parameters are there (verified by using some simple hidden inputs which have values)

    @await Component.InvokeAsync(Inventory.ModelTypeAlias, new
        type = type,
        year = year,
        make = make,
        model = model,
        priceRange = priceRange,
        sortBy = sortBy,
        page = page

    This next part however, loses parameters (they are all empty) - only on Umbraco Cloud. On my MacOS machine, for some reason, parameters get there correctly

    View Component:

    public async Task<IViewComponentResult> InvokeAsync(
            [FromQuery(Name = "type")] string type,
            [FromQuery(Name = "year")] string year,
            [FromQuery(Name = "make")] string make,
            [FromQuery(Name = "model")] string model,
            [FromQuery(Name = "priceRange")] string priceRange,
            [FromQuery(Name = "sortBy")] string sortBy,
            [FromQuery(Name = "page")] string page,
            CancellationToken cancellationToken = default)
    .... empty params

    I can't find any logical reason why parameters would get to the view component on my machine, but not on Umbraco Cloud.

    Need help please.

  • Daniel Hursan 4 posts 64 karma points
    Jan 25, 2024 @ 17:12
    Daniel Hursan

    FYI, when I send parameters to the view component, they are sent like this

    string year = Context.Request.Query["year"].Count > 0 ? Context.Request.Query["year"].FirstOrDefault() : string.Empty;
    year = year,

    Posting the Umbraco Cloud url too, if this helps narrowing down the issue:

  • Dennis Pedersen 4 posts 115 karma points
    Jan 25, 2024 @ 19:29
    Dennis Pedersen

    Is there a reason you dont create a viewmodel for your data? not sure this helps you in this case - but I personally would always do that.

  • Steve Morgan 1346 posts 4455 karma points c-trib
    Jan 26, 2024 @ 10:22
    Steve Morgan

    Is it possible the url is malformed / parameter values are not properly encoded? Some servers may block urls that have potentially damaging url parameters (think of the old sql injection).

    That might explain why it works locally.

    Try analysing your url to see if there's any characters in there or unencoded entities (spaces, special chars).

  • Daniel Hursan 4 posts 64 karma points
    Jan 26, 2024 @ 10:25
    Daniel Hursan

    Just figured it out. I did a lot of logging to figure out where parameters are lost, and I narrowed it down as a matter of view rendering (parameters were getting correctly to view component, view model was set correctly)

    I removed caching from the way I was invoking my partials and it worked!

    Change from:

    @await Html.CachedPartialAsync("~/Views/Partials/InventoryGridFilters.cshtml", @Model,

    Changed to

    @await Html.PartialAsync("~/Views/Partials/InventoryGridFilters.cshtml", @Model)
  • Steve Morgan 1346 posts 4455 karma points c-trib
    Jan 26, 2024 @ 10:45
    Steve Morgan

    Ah - I should have thought of this.

    Caching is only enabled on live. The times I've tested things locally - forgetting it's a debug build and then scratched my head on live.

Please Sign in or register to post replies

Write your reply to: