Skip to content

Use given model nullability in razor pages #37510

Closed

Description

We are migrating our 5.0 project to 6.0-rc2 and noticed that RazorPage.Model was changed to always be nullable, even though model type in razor file is specified as not null. Because of this, we are getting thousands of compile time errors on any model access outside of asp-for expressions like asp-route-id="@Model.Id".

Describe the solution you'd like

Would it be possible to change it to TModel from TModel??
So we can tell the razor page if model is possibly null or not in the view?

@model MyModel?

Additional context

My guess is that razor doesn't parse nullable models in views, so it wasn't made that way because of that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

Priority:1Work that is critical for the release, but we could probably ship withoutarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatescost: MWill take from 3 - 5 days to completeenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-razor-pages

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions