Is there an existing issue for this?
Describe the bug
After upgrading my app to use ASP.NET 7, my search forms now produce query strings that contain additional (unnecessary?) parameters.
The Problem
The search forms on my site use the GET method so that searches can be bookmarked & shared. (Google does the same thing.) So a typical search result URL might look like:
https://localhost/Public?SearchDate=2023-04-06
But because of the work done in #43182, the HTML now contains additional hidden input fields to inform the parser about "which inputs need culture-invariant parsing", and now the same search form produces this URL:
https://localhost/Public?SearchDate=2023-04-06&__Invariant=Spec.SearchDate
... which isn't terrible, but consider that my search forms might contain a dozen fields, several of which get similarly doubled.
Code used for this example...
<input asp-for="Spec.SearchDate" name="@nameof(Model.Spec.SearchDate)" />
The input element includes a name attribute because I use a DTO instead of putting all the search fields directly in the page model:
// Search form DTO
public class SearchDto
{
[DataType(DataType.Date)]
public DateTime? SearchDate { get; init; }
// ...
}
// Page model
public class IndexModel : PageModel
{
public SearchDto Spec { get; set; } = default!;
// ...
}
Concerns
The new URL is unnecessarily cluttered. This is an aesthetic issue, but aesthetics is important. It adds value when the user (and programmer!) can understand the URL. Also, creating a new search by editing the URL is more cumbersome and intimidating, and possibly more error prone.
I'm also concerned about how this will affect existing bookmarks. My guess is that some old bookmarks may have been affected by the bug that was fixed, so it's hard to say how they will work under the new behavior.
Finally -- and this is a secondary issue -- but why can't the new parameter at least use the shorter name SearchDate I specified instead of Spec.SearchDate?
Based on my limited testing, removing the __Invariant parameters from the search string didn't affect how the values were parsed. It seems to me that since FormInputRenderMode is an all or nothing setting, you could just determine how to parse all dates and numbers based on that setting, rather than get an extra parameter for each date & number field.
Expected Behavior
Cool URIs don't change 😉
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
7.0.202
Anything else?
No response
Is there an existing issue for this?
Describe the bug
After upgrading my app to use ASP.NET 7, my search forms now produce query strings that contain additional (unnecessary?) parameters.
The Problem
The search forms on my site use the GET method so that searches can be bookmarked & shared. (Google does the same thing.) So a typical search result URL might look like:
https://localhost/Public?SearchDate=2023-04-06But because of the work done in #43182, the HTML now contains additional hidden
inputfields to inform the parser about "which inputs need culture-invariant parsing", and now the same search form produces this URL:https://localhost/Public?SearchDate=2023-04-06&__Invariant=Spec.SearchDate... which isn't terrible, but consider that my search forms might contain a dozen fields, several of which get similarly doubled.
Code used for this example...
The
inputelement includes anameattribute because I use a DTO instead of putting all the search fields directly in the page model:Concerns
The new URL is unnecessarily cluttered. This is an aesthetic issue, but aesthetics is important. It adds value when the user (and programmer!) can understand the URL. Also, creating a new search by editing the URL is more cumbersome and intimidating, and possibly more error prone.
I'm also concerned about how this will affect existing bookmarks. My guess is that some old bookmarks may have been affected by the bug that was fixed, so it's hard to say how they will work under the new behavior.
Finally -- and this is a secondary issue -- but why can't the new parameter at least use the shorter name
SearchDateI specified instead ofSpec.SearchDate?Based on my limited testing, removing the
__Invariantparameters from the search string didn't affect how the values were parsed. It seems to me that sinceFormInputRenderModeis an all or nothing setting, you could just determine how to parse all dates and numbers based on that setting, rather than get an extra parameter for each date & number field.Expected Behavior
Cool URIs don't change 😉
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
7.0.202
Anything else?
No response