-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Receive "The returnUrl field is required" validation error when enabling Nullable reference types #22656
Comments
Changing the OnGetAsync parameter from to Solves the error. Maybe good to note in documentation somewhere as it took a bit to find the exact cause. Hopefully helps others... |
What do we want to do here @blowdart generating different scaffolding code based on nullability options is not something we currently are planning are we? |
Oh dear. I honestly don't know, I'd assume that we want to support nullability, which in turn may need scaffolding changes. @Pilchie @DamianEdwards this is probably an opinion for you to weigh in on. |
I'm confused as to how this causes a runtime error? The nullable annotations in the C# compiler shouldn't change the generated code afaik. |
Yeah its weird that turning on the feature would cause a different runtime behavior, but wrt to the general question: From https://devblogs.microsoft.com/dotnet/embracing-nullable-reference-types/ "We strongly encourage authors of libraries (and similar infrastructure, such as code generators) to adopt NRTs during the nullable rollout phase." Should we be updating the identity ui code + scaffolded output to support nullable reference types in 5.0, basically to make this flow just work (scaffold all + enable nullable) |
Ideally yes. @pranavkm has already been looking at adding nullable annotations to a bunch of the ASP.NET Core code in the last few weeks. |
MVC infers that all non-nullable types are required - https://docs.microsoft.com/en-us/aspnet/core/mvc/models/validation?view=aspnetcore-3.1#required-attribute. |
If we change the template would it break if you have have nullable types off? |
You can enable or disable nullables on individual C# files using pragmas.
I don't know what the equivalent gesture is for .cshtml files (@NTaylorMullen). |
We don't have one to apply to the entire file sadly. Razor files inherit the projects nullability so if you turn it on the for the entire project then Razor files will have it turned on. |
Closing in favor of aggregating issue, #25310 |
Describe the bug
When enabling nullable reference types I receive a validation error "The returnUrl field is required" when navigating to:
~/Identity/Account/Register
or
~/Identity/Account/Login
To Reproduce
Start from a new aspnetcore identity template with individual account, all views scaffolded. Then enable Nullable reference types in the project,
<Nullable>enable</Nullable>
Navigate to
~/Identity/Account/Register
. You should see in the validation summary"The returnUrl field is required"
Further technical details
The text was updated successfully, but these errors were encountered: