dotnet / dotnet/Scaffolding

C#8 Nullable ref types - returnUrl field is required

Open
#1,270 1 comment 1 reaction 0 assignees View on GitHub
area-scaffolding
Dominant language
C#
Stars
818
Forks
260
Avg merge
1d 8h
Merged PRs (30d)
10

Description

Moved from https://github.com/dotnet/AspNetCore.Docs/issues/17145 by @djhmateer

When scaffolding out the Identity code and I have C#8 nullable ref types checking set in the .csproj

```
enable
```
I need to change the methods which have a default value set to null eg

```
public async Task OnGetAsync(string returnUrl = null)
```

to be a nullable string ie `string?` otherwise, the UI will set ModelState error giving returnUrl field is required

---
#### Document details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 804e24dd-7e30-8cf5-2c99-1ffacb4582f6
* Version Independent ID: 3e25547b-e2c9-6634-2c38-2a77207f17d4
* Content: [Scaffold Identity in ASP.NET Core projects](https://docs.microsoft.com/en-gb/aspnet/core/security/authentication/scaffold-identity?view=aspnetcore-3.1&tabs=netcore-cli#scaffold-identity-into-a-razor-project-with-authorization)
* Content Source: [aspnetcore/security/authentication/scaffold-identity.md](https://github.com/dotnet/AspNetCore.Docs/blob/master/aspnetcore/security/authentication/scaffold-identity.md)
* Product: **aspnet-core**
* Technology: **aspnetcore-security**
* GitHub Login: @Rick-Anderson
* Microsoft Alias: **riande**

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.