Skip to content

Commit 7db5526

Browse files
committed
Enable nullable references in project templates
Contributes to #33947
1 parent 179c2b5 commit 7db5526

File tree

54 files changed

+97
-52
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+97
-52
lines changed

src/ProjectTemplates/Web.ProjectTemplates/BlazorServerWeb-CSharp.csproj.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
5+
<Nullable>enable</Nullable>
56
<UserSecretsId Condition="'$(IndividualAuth)' == 'True' OR '$(OrganizationalAuth)' == 'True'">aspnet-BlazorServerWeb_CSharp-53bc9b9d-9d6a-45d4-8429-2a2761773502</UserSecretsId>
67
<WebProject_DirectoryAccessLevelKey Condition="'$(OrganizationalAuth)' == 'True' AND '$(OrgReadAccess)' != 'True'">0</WebProject_DirectoryAccessLevelKey>
78
<WebProject_DirectoryAccessLevelKey Condition="'$(OrganizationalAuth)' == 'True' AND '$(OrgReadAccess)' == 'True'">1</WebProject_DirectoryAccessLevelKey>

src/ProjectTemplates/Web.ProjectTemplates/ComponentsWebAssembly-CSharp.Client.csproj.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
5+
<Nullable>enable</Nullable>
56
<!--#if PWA -->
67
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
78
<!--#endif -->

src/ProjectTemplates/Web.ProjectTemplates/ComponentsWebAssembly-CSharp.Server.csproj.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
5+
<Nullable>enable</Nullable>
56
<UserSecretsId Condition="'$(IndividualAuth)' == 'True' OR '$(OrganizationalAuth)' == 'True'">ComponentsWebAssembly-CSharp.Server-53bc9b9d-9d6a-45d4-8429-2a2761773502</UserSecretsId>
67
<WebProject_DirectoryAccessLevelKey Condition="'$(OrganizationalAuth)' == 'True' AND '$(OrgReadAccess)' != 'True'">0</WebProject_DirectoryAccessLevelKey>
78
<WebProject_DirectoryAccessLevelKey Condition="'$(OrganizationalAuth)' == 'True' AND '$(OrgReadAccess)' == 'True'">1</WebProject_DirectoryAccessLevelKey>

src/ProjectTemplates/Web.ProjectTemplates/ComponentsWebAssembly-CSharp.Shared.csproj.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
5+
<Nullable>enable</Nullable>
56
</PropertyGroup>
67

78
<ItemGroup>

src/ProjectTemplates/Web.ProjectTemplates/EmptyWeb-CSharp.csproj.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
5+
<Nullable>enable</Nullable>
56
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
67
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>
78
<LangVersion>preview</LangVersion>

src/ProjectTemplates/Web.ProjectTemplates/GrpcService-CSharp.csproj.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
5+
<Nullable>enable</Nullable>
56
</PropertyGroup>
67

78
<ItemGroup>

src/ProjectTemplates/Web.ProjectTemplates/RazorClassLibrary-CSharp.csproj.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
5+
<Nullable>enable</Nullable>
56
<AddRazorSupportForMvc Condition="'$(SupportPagesAndViews)' == 'True'">true</AddRazorSupportForMvc>
67
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.RazorClassLibrary1</RootNamespace>
78
</PropertyGroup>

src/ProjectTemplates/Web.ProjectTemplates/RazorPagesWeb-CSharp.csproj.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
5+
<Nullable>enable</Nullable>
56
<UserSecretsId Condition="'$(IndividualAuth)' == 'True' OR '$(OrganizationalAuth)' == 'True'">aspnet-Company.WebApplication1-0ce56475-d1db-490f-8af1-a881ea4fcd2d</UserSecretsId>
67
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
78
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>

src/ProjectTemplates/Web.ProjectTemplates/StarterWeb-CSharp.csproj.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
5+
<Nullable>enable</Nullable>
56
<UserSecretsId Condition="'$(IndividualAuth)' == 'True' OR '$(OrganizationalAuth)' == 'True'">aspnet-Company.WebApplication1-53bc9b9d-9d6a-45d4-8429-2a2761773502</UserSecretsId>
67
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
78
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>

src/ProjectTemplates/Web.ProjectTemplates/WebApi-CSharp.csproj.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
5+
<Nullable>enable</Nullable>
56
<UserSecretsId Condition="'$(IndividualAuth)' == 'True' OR '$(OrganizationalAuth)' == 'True'">aspnet-Company.WebApplication1-53bc9b9d-9d6a-45d4-8429-2a2761773502</UserSecretsId>
67
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
78
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.WebApplication1</RootNamespace>

src/ProjectTemplates/Web.ProjectTemplates/Worker-CSharp.csproj.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>${DefaultNetCoreTargetFramework}</TargetFramework>
5+
<Nullable>enable</Nullable>
56
<UserSecretsId>dotnet-Company.Application1-53bc9b9d-9d6a-45d4-8429-2a2761773502</UserSecretsId>
67
<NoDefaultLaunchSettingsFile Condition="'$(ExcludeLaunchSettings)' == 'True'">True</NoDefaultLaunchSettingsFile>
78
<RootNamespace Condition="'$(name)' != '$(name{-VALUE-FORMS-}safe_namespace)'">Company.Application1</RootNamespace>

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Areas/Identity/Pages/Shared/_LoginPartial.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
@if (SignInManager.IsSignedIn(User))
88
{
99
<li class="nav-item">
10-
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity.Name!</a>
10+
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity?.Name!</a>
1111
</li>
1212
<li class="nav-item">
1313
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="/" method="post">

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Data/WeatherForecast.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ public class WeatherForecast
1010

1111
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
1212

13-
public string Summary { get; set; }
13+
public string? Summary { get; set; }
1414
}
1515
}

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Pages/Error.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace BlazorServerWeb_CSharp.Pages
1313
[IgnoreAntiforgeryToken]
1414
public class ErrorModel : PageModel
1515
{
16-
public string RequestId { get; set; }
16+
public string? RequestId { get; set; }
1717

1818
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
1919

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Pages/FetchData.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ else
3737
}
3838

3939
@code {
40-
private WeatherForecast[] forecasts;
40+
private WeatherForecast[]? forecasts;
4141

4242
protected override async Task OnInitializedAsync()
4343
{

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Shared/LoginDisplay.IndividualB2CAuth.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
<Authorized>
77
@if (canEditProfile)
88
{
9-
<a href="MicrosoftIdentity/Account/EditProfile">Hello, @context.User.Identity.Name!</a>
9+
<a href="MicrosoftIdentity/Account/EditProfile">Hello, @context.User.Identity?.Name!</a>
1010
}
1111
else
1212
{
13-
<text>Hello, @context.User.Identity.Name!</text>
13+
<text>Hello, @context.User.Identity?.Name!</text>
1414
}
1515
<a href="MicrosoftIdentity/Account/SignOut">Log out</a>
1616
</Authorized>

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Shared/LoginDisplay.IndividualLocalAuth.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<AuthorizeView>
22
<Authorized>
3-
<a href="Identity/Account/Manage">Hello, @context.User.Identity.Name!</a>
3+
<a href="Identity/Account/Manage">Hello, @context.User.Identity?.Name!</a>
44
<form method="post" action="Identity/Account/LogOut">
55
<button type="submit" class="nav-link btn btn-link">Log out</button>
66
</form>

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Shared/LoginDisplay.OrganizationalAuth.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<AuthorizeView>
22
<Authorized>
3-
Hello, @context.User.Identity.Name!
3+
Hello, @context.User.Identity?.Name!
44
<a href="MicrosoftIdentity/Account/SignOut">Log out</a>
55
</Authorized>
66
<NotAuthorized>
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
<AuthorizeView>
2-
Hello, @context.User.Identity.Name!
2+
Hello, @context.User.Identity?.Name!
33
</AuthorizeView>

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Shared/NavMenu.CallsMicrosoftGraph.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
@code {
3434
private bool collapseNavMenu = true;
3535

36-
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
36+
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
3737

3838
private void ToggleNavMenu()
3939
{

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Shared/NavMenu.CallsWebApi.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
@code {
3434
private bool collapseNavMenu = true;
3535

36-
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
36+
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
3737

3838
private void ToggleNavMenu()
3939
{

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Shared/NavMenu.NoGraphOrApi.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
@code {
2929
private bool collapseNavMenu = true;
3030

31-
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
31+
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
3232

3333
private void ToggleNavMenu()
3434
{

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorServerWeb-CSharp/Shared/SurveyPrompt.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
@code {
1313
// Demonstrates how a parent component can supply parameters
1414
[Parameter]
15-
public string Title { get; set; }
15+
public string? Title { get; set; }
1616
}

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/Pages/FetchData.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ else
4545
}
4646

4747
@code {
48-
private WeatherForecast[] forecasts;
48+
private WeatherForecast[]? forecasts;
4949

5050
protected override async Task OnInitializedAsync()
5151
{
@@ -74,7 +74,7 @@ else
7474
7575
public int TemperatureC { get; set; }
7676
77-
public string Summary { get; set; }
77+
public string? Summary { get; set; }
7878
7979
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
8080
}

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/Shared/LoginDisplay.IndividualLocalAuth.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<AuthorizeView>
88
@*#if (Hosted)
99
<Authorized>
10-
<a href="authentication/profile">Hello, @context.User.Identity.Name!</a>
10+
<a href="authentication/profile">Hello, @context.User.Identity?.Name!</a>
1111
<button class="nav-link btn btn-link" @onclick="BeginSignOut">Log out</button>
1212
</Authorized>
1313
<NotAuthorized>
@@ -16,7 +16,7 @@
1616
</NotAuthorized>
1717
#else
1818
<Authorized>
19-
Hello, @context.User.Identity.Name!
19+
Hello, @context.User.Identity?.Name!
2020
<button class="nav-link btn btn-link" @onclick="BeginSignOut">Log out</button>
2121
</Authorized>
2222
<NotAuthorized>

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/Shared/LoginDisplay.IndividualMsalAuth.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<AuthorizeView>
88
<Authorized>
9-
Hello, @context.User.Identity.Name!
9+
Hello, @context.User.Identity?.Name!
1010
<button class="nav-link btn btn-link" @onclick="BeginLogout">Log out</button>
1111
</Authorized>
1212
<NotAuthorized>

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/Shared/NavMenu.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
@code {
2929
private bool collapseNavMenu = true;
3030

31-
private string NavMenuCssClass => collapseNavMenu ? "collapse" : null;
31+
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null;
3232

3333
private void ToggleNavMenu()
3434
{

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Client/Shared/SurveyPrompt.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
@code {
1313
// Demonstrates how a parent component can supply parameters
1414
[Parameter]
15-
public string Title { get; set; }
15+
public string? Title { get; set; }
1616
}

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Areas/Identity/Pages/Shared/_LoginPartial.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
@if (SignInManager.IsSignedIn(User))
1616
{
1717
<li class="nav-item">
18-
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity.Name!</a>
18+
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity?.Name!</a>
1919
</li>
2020
<li class="nav-item">
2121
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="/" method="post">

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Server/Pages/Error.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace ComponentsWebAssembly_CSharp.Server.Pages
1313
[IgnoreAntiforgeryToken]
1414
public class ErrorModel : PageModel
1515
{
16-
public string RequestId { get; set; }
16+
public string? RequestId { get; set; }
1717

1818
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
1919

src/ProjectTemplates/Web.ProjectTemplates/content/ComponentsWebAssembly-CSharp/Shared/WeatherForecast.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class WeatherForecast
1010

1111
public int TemperatureC { get; set; }
1212

13-
public string Summary { get; set; }
13+
public string? Summary { get; set; }
1414

1515
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
1616
}

src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Pages/Error.cshtml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace Company.WebApplication1.Pages
1313
[IgnoreAntiforgeryToken]
1414
public class ErrorModel : PageModel
1515
{
16-
public string RequestId { get; set; }
16+
public string? RequestId { get; set; }
1717

1818
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
1919

src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Pages/Shared/_Layout.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
@*#if (IndividualAuth || OrganizationalAuth)
2929
<partial name="_LoginPartial" />
3030
#elseif (WindowsAuth)
31-
<p class="nav navbar-text">Hello, @User.Identity.Name!</p>
31+
<p class="nav navbar-text">Hello, @User.Identity?.Name!</p>
3232
#endif*@
3333
</div>
3434
</div>

src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Pages/Shared/_LoginPartial.Identity.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@if (SignInManager.IsSignedIn(User))
77
{
88
<li class="nav-item">
9-
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity.Name!</a>
9+
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity?.Name!</a>
1010
</li>
1111
<li class="nav-item">
1212
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Page("/", new { area = "" })" method="post" >

src/ProjectTemplates/Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Pages/Shared/_LoginPartial.OrgAuth.cshtml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@
1111

1212
<ul class="navbar-nav">
1313
@*#if (IndividualB2CAuth)
14-
@if (User.Identity.IsAuthenticated)
14+
@if (User.Identity?.IsAuthenticated == true)
1515
{
1616
@if (!string.IsNullOrEmpty(options.EditProfilePolicyId))
1717
{
1818
<li class="nav-item">
1919
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="EditProfile">
20-
<span class="text-dark">Hello @User.Identity.Name!</span>
20+
<span class="text-dark">Hello @User.Identity?.Name!</span>
2121
</a>
2222
</li>
2323
}
2424
else
2525
{
2626
<li class="nav-item">
27-
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span>
27+
<span class="navbar-text text-dark">Hello @User.Identity?.Name!</span>
2828
</li>
2929
}
3030
<li class="nav-item">
@@ -38,10 +38,10 @@ else
3838
</li>
3939
}
4040
#else
41-
@if (User.Identity.IsAuthenticated)
41+
@if (User.Identity?.IsAuthenticated == true)
4242
{
4343
<li class="nav-item">
44-
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span>
44+
<span class="navbar-text text-dark">Hello @User.Identity?.Name!</span>
4545
</li>
4646
<li class="nav-item">
4747
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" asp-controller="Account" asp-action="SignOut">Sign out</a>

src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Models/ErrorViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace Company.WebApplication1.Models
44
{
55
public class ErrorViewModel
66
{
7-
public string RequestId { get; set; }
7+
public string? RequestId { get; set; }
88

99
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
1010
}

src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/Error.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
<h1 class="text-danger">Error.</h1>
77
<h2 class="text-danger">An error occurred while processing your request.</h2>
88

9-
@if (Model.ShowRequestId)
9+
@if (Model?.ShowRequestId ?? false)
1010
{
1111
<p>
12-
<strong>Request ID:</strong> <code>@Model.RequestId</code>
12+
<strong>Request ID:</strong> <code>@Model?.RequestId</code>
1313
</p>
1414
}
1515

src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/_Layout.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
@*#if (IndividualAuth || OrganizationalAuth)
2929
<partial name="_LoginPartial" />
3030
#elseif (WindowsAuth)
31-
<p class="nav navbar-text">Hello, @User.Identity.Name!</p>
31+
<p class="nav navbar-text">Hello, @User.Identity?.Name!</p>
3232
#endif*@
3333
</div>
3434
</div>

src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/_LoginPartial.Identity.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@if (SignInManager.IsSignedIn(User))
77
{
88
<li class="nav-item">
9-
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity.Name!</a>
9+
<a class="nav-link text-dark" asp-area="Identity" asp-page="/Account/Manage/Index" title="Manage">Hello @User.Identity?.Name!</a>
1010
</li>
1111
<li class="nav-item">
1212
<form class="form-inline" asp-area="Identity" asp-page="/Account/Logout" asp-route-returnUrl="@Url.Action("Index", "Home", new { area = "" })">

0 commit comments

Comments
 (0)