active-directory-aspnetcore-webapp-openidconnect-v2 icon indicating copy to clipboard operation
active-directory-aspnetcore-webapp-openidconnect-v2 copied to clipboard

3-WebApp-multi-APIs Sample Broken - site doesn't load when targetting: .net 6.0 framework

Open Mson888 opened this issue 3 years ago • 2 comments

3-WebApp-multi-APIs no longer works after changing from .net core 3.1 to .net framework 6.0 target runtime

This issue is for a: (mark with an x)

- [] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [X ] regression (a behavior that used to work and stopped in a new release)

The issue was found for the following scenario:

3-WebApp-multi-APIs no longer works after changing from .net core 3.1 to .net framework 6.0 target runtime

Please add an 'x' for the scenario(s) where you found an issue

  1. Web app that signs in users
    1. [ ] with a work and school account in your organization: 1-WebApp-OIDC/1-1-MyOrg
    2. [ ] with any work and school account: /1-WebApp-OIDC/1-2-AnyOrg
    3. [ ] with any work or school account or Microsoft personal account: 1-WebApp-OIDC/1-3-AnyOrgOrPersonal
    4. [ ] with users in National or sovereign clouds 1-WebApp-OIDC/1-4-Sovereign
    5. [ ] with B2C users 1-WebApp-OIDC/1-5-B2C
  2. Web app that calls Microsoft Graph
    1. [ ] Calling graph with the Microsoft Graph SDK: 2-WebApp-graph-user/2-1-Call-MSGraph
    2. [ ] With specific token caches: 2-WebApp-graph-user/2-2-TokenCache
    3. [X] 2-3 Multi-tenant
    4. [ ] Calling Microsoft Graph in national clouds: 2-WebApp-graph-user/2-4-Sovereign-Call-MSGraph
  3. [X] Web app calling several APIs 3-WebApp-multi-APIs
  4. [ ] Web app calling your own Web API
    1. [ ] with a work and school account in your organization: 4-WebApp-your-API/4-1-MyOrg
    2. [ ] with B2C users: 4-WebApp-your-API/4-2-B2C
    3. [ ] with any work and school account: 4-WebApp-your-API/4-3-AnyOrg
  5. Web app restricting users
    1. [ ] by Roles: 5-WebApp-AuthZ/5-1-Roles
    2. [ ] by Groups: 5-WebApp-AuthZ/5-2-Groups
  6. [ ] Deployment to Azure
  7. [ ] Other (please describe)

Repro-ing the issue

Repro steps

  1. Clone repository
  2. install min. requirements
  3. Follow steps to set up the app, populate config etc.
  4. Build (on VS2022) and deploy (F5)
  5. Try to log in as a valid user

Expected behavior Site loads. tabs work.

Actual behavior Site doesn't load. Unable to find index.cshtml

Internal Server Error InvalidOperationException: The view 'Index' was not found. The following locations were searched: /Views/Home/Index.cshtml /Views/Shared/Index.cshtml /Pages/Shared/Index.cshtml Microsoft.AspNetCore.Mvc.ViewEngines.ViewEngineResult.EnsureSuccessful(IEnumerable originalLocations)

Possible Solution

  • revert back to .netcore3.1 ie. back to <TargetFramework>netcoreapp3.1</TargetFramework> from <TargetFramework>net6.0</TargetFramework> doing this - confirmed that the site loads once again.

  • If using .net 6.0 - unsure -> Ensure the route registration works or .cshtml are always deployed?

Additional context/ Error codes / Screenshots

image

Any log messages given by the failure

Add any other context about the problem here, such as logs. N/A

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?) Windwos 10

Versions

of ASP.NET Core, of MSAL.NET not sure - the project says .net core but the targeting framework is .net framework x64 runtime as of the change https://github.com/Azure-Samples/active-directory-aspnetcore-webapp-openidconnect-v2/commit/2607df1338a9f7c06fe228c87644b8b456ca708b

Attempting to troubleshooting yourself:

Mention any other details that might be useful


Thanks! We'll be in touch soon.

Mson888 avatar Feb 20 '22 22:02 Mson888

It works when I start the app via dotnet run instead of F5. Not sure why though.

jerry1100 avatar Mar 09 '22 22:03 jerry1100

Similar issue was encountered in sample 2-3 and should be resolved with PR 593.

It seems the issue here is routing in the Startup.cs file.

PR 594 should resolve this. Tested this code with VS 2022 and dotnet CLI without issue.

v-michaelmi avatar Mar 31 '22 00:03 v-michaelmi

Issue resolved with commit 2607

Closing.

v-michaelmi avatar Sep 01 '22 21:09 v-michaelmi