diff --git a/src/Mvc/Mvc.Razor/src/PublicAPI.Unshipped.txt b/src/Mvc/Mvc.Razor/src/PublicAPI.Unshipped.txt index 7dc5c58110bf..5b615e3dde8c 100644 --- a/src/Mvc/Mvc.Razor/src/PublicAPI.Unshipped.txt +++ b/src/Mvc/Mvc.Razor/src/PublicAPI.Unshipped.txt @@ -1 +1,3 @@ #nullable enable +*REMOVED*Microsoft.AspNetCore.Mvc.Razor.RazorPage.Model.get -> TModel? +Microsoft.AspNetCore.Mvc.Razor.RazorPage.Model.get -> TModel diff --git a/src/Mvc/Mvc.Razor/src/RazorPageOfT.cs b/src/Mvc/Mvc.Razor/src/RazorPageOfT.cs index eb1151617773..cc0ae56e1f1f 100644 --- a/src/Mvc/Mvc.Razor/src/RazorPageOfT.cs +++ b/src/Mvc/Mvc.Razor/src/RazorPageOfT.cs @@ -15,13 +15,12 @@ public abstract class RazorPage : RazorPage /// /// Gets the Model property of the property. /// - public TModel? Model => ViewData == null ? default(TModel) : ViewData.Model; + public TModel Model => ViewData.Model; /// /// Gets or sets the dictionary for view data. /// [RazorInject] public ViewDataDictionary ViewData { get; set; } = default!; - } } diff --git a/src/Mvc/Mvc.ViewFeatures/src/PublicAPI.Unshipped.txt b/src/Mvc/Mvc.ViewFeatures/src/PublicAPI.Unshipped.txt index 7dc5c58110bf..73d4cbd64fd1 100644 --- a/src/Mvc/Mvc.ViewFeatures/src/PublicAPI.Unshipped.txt +++ b/src/Mvc/Mvc.ViewFeatures/src/PublicAPI.Unshipped.txt @@ -1 +1,3 @@ #nullable enable +*REMOVED*Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Model.get -> TModel? +Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Model.get -> TModel diff --git a/src/Mvc/Mvc.ViewFeatures/src/ViewDataDictionaryOfT.cs b/src/Mvc/Mvc.ViewFeatures/src/ViewDataDictionaryOfT.cs index 3640fdea0281..9933bfe667d5 100644 --- a/src/Mvc/Mvc.ViewFeatures/src/ViewDataDictionaryOfT.cs +++ b/src/Mvc/Mvc.ViewFeatures/src/ViewDataDictionaryOfT.cs @@ -86,16 +86,10 @@ internal ViewDataDictionary(IModelMetadataProvider metadataProvider) } /// - public new TModel? Model + public new TModel Model { - get - { - return (base.Model == null) ? default(TModel) : (TModel)base.Model; - } - set - { - base.Model = value; - } + get => (base.Model is null) ? default! : (TModel)base.Model; + set => base.Model = value; } } } diff --git a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/Error.cshtml b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/Error.cshtml index 10cf32b713d0..a1e04783c67a 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/Error.cshtml +++ b/src/ProjectTemplates/Web.ProjectTemplates/content/StarterWeb-CSharp/Views/Shared/Error.cshtml @@ -6,10 +6,10 @@

Error.

An error occurred while processing your request.

-@if (Model?.ShowRequestId ?? false) +@if (Model.ShowRequestId) {

- Request ID: @Model?.RequestId + Request ID: @Model.RequestId

}