Aspnetcore.docs: 3.0 Migration Discuss RazorPages AllowAreas option

Created on 17 Sep 2019  Â·  9Comments  Â·  Source: dotnet/AspNetCore.Docs

[EDIT by guardrex to add the metadata for the migration topic]

In the 2.2 -> 3.0 Migration guide, cover what do with this:

                .AddRazorPagesOptions(options =>
                {
                    options.Conventions.AuthorizePage("/Basket/Checkout");
                    options.AllowAreas = true; // THIS LINE
                })

The line noted above triggers this error in 3.0 latest preview:

Error | CS1061 | 'RazorPagesOptions' does not contain a definition for 'AllowAreas' and no accessible extension method 'AllowAreas' accepting a first argument of type 'RazorPagesOptions' could be found (are you missing a using directive or an assembly reference?)

I don't know what nuget package, if any, can be added to fix this.


Document Details

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

Most helpful comment

@pranavkm Thanks! I'm fine with removing it of course. My issue was that in the course of upgrading an app from 2.2 to 3.0 I had a bunch of missing references (due mostly to things coming out of Microsoft.AspNetCore.App) and this error blended in with those. So I spent at least 20 minutes trying to figure out which Nuget package I had to add to fix the error. Including a note that it can be removed in the migration guide will hopefully save others (and probably future me) from this frustration.

All 9 comments

Thus far, I see it was removed here :point_right: https://github.com/aspnet/AspNetCore/commit/f113a20dfd9d0c7c991e425fd8000ed6b64d19a5#diff-5c43af172dc698a7587dca36319961fc

... but is the default for areas to allow them? ... are u saying if you remove that and run it that the areas aren't allowed by default?

AllowAreas is a compatibility switch. With 3.0 being a breaking change, Areas are "allowed" out of the box, so options.AllowAreas = true; can be dropped.

Nice one @serpent5 ... I saw a passing remark on it but didn't have confirmation from the commit that dropped it.

I'd mention that it can be removed in the migration doc. Otherwise it's going to be a compiler error customers are going to spend time trying to track down (instead of just deleting that line).

@Rick-Anderson should add it, as he's managing the topic.

@ardalis the feature is on by default (and there isn't a way to disable it). It was added as a compat switch for apps migrating from 2.1 -> 2.2 since it introduced a breaking behavior change. Removing it in 3.0 would be the right thing to do.

@pranavkm I'll update Compatibility version and in the release notes mention the compatibility features have been removed for 3.0

@pranavkm Thanks! I'm fine with removing it of course. My issue was that in the course of upgrading an app from 2.2 to 3.0 I had a bunch of missing references (due mostly to things coming out of Microsoft.AspNetCore.App) and this error blended in with those. So I spent at least 20 minutes trying to figure out which Nuget package I had to add to fix the error. Including a note that it can be removed in the migration guide will hopefully save others (and probably future me) from this frustration.

AllowAreas is listed in github.com/aspnet/Announcements label:"Breaking change" in issue Breaking API changes in Antiforgery, Cors, Diagnostics, Mvc, and Routing #387

The migration guide has a link to the breaking issues. I don't want to repeat that info in the migration guide. Folks who hit this google will find this issue. If enough hit it, I'll consider adding it to the migration guide.

Was this page helpful?
0 / 5 - 0 ratings