The Wayback Machine - https://web.archive.org/web/20211113125351/https://github.com/dotnet/aspnetcore/issues/38354
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Areas do not work in ASP.NET Core with Angular project #38354

Open
dushkostanoeski opened this issue Nov 13, 2021 · 0 comments
Open

Areas do not work in ASP.NET Core with Angular project #38354

dushkostanoeski opened this issue Nov 13, 2021 · 0 comments

Comments

Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
@dushkostanoeski
Copy link

@dushkostanoeski dushkostanoeski commented Nov 13, 2021

Describe the bug

Making calls to controllers that have an area attribute returns 404

To Reproduce

Create a new ASP.NET Core with Angular project, add an Areas folder and in it another Weather folder. Move the Controllers folder into the Weather folder.

Change the namespace of the WeatherForecastController class to Project1.Areas.Weather.Controllers and change the attributes to the following:

[ApiController]
[Route("[area]/[controller]")]
[Area("Weather")]

In Program.cs add the following line before the default route (I tried this with UseEndpoints() but got the same result):

app.MapControllerRoute("areas", "{areas:exist}/{controller}/{action=Index}/{id?}");

and at last add weather/ to the url in the http.get call in the fetch-data angular controller.

Once you run the app, you get 404 when making the API call.

Further technical details

  • ASP.NET Core version: 6.0.0
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version: Visual Studio 2022
  • Include the output of dotnet --info:
dotnet --info Output
.NET SDK (reflecting any global.json):
 Version:   6.0.100
 Commit:    9e8b04bbff

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.100\

Host (useful for support):
  Version: 6.0.0
  Commit:  4822e3c3aa

.NET SDKs installed:
  6.0.100 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment