by

Recently I was trying to update a query string by adding or updating a parameter for URLs generated in a partial view.

I found an excellent example for achieving this by setting route data here however this didn’t preserve current query string values in the URL. I’ve extended upon that code and updated it to include the query string values in the route data which will be appended to the query string in the generated URL (assuming the parameter key doesn’t match part of the route).