Closed Alin764 closed 7 months ago
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
@James764 thanks for contacting us.
We've significantly changed our approach to developing SPAs in .NET 6.0 and as a result we no longer make use of the SpaProxyMiddleware in our templates. The changes can be ported to earlier versions of the SPA templates, so we suggest you update your app to copy the SPA files to the approach used in 6.0
Thanks for contacting us.
We're moving this issue to the .NET 7 Planning
milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
This issue frequently occurs when running any of the popular web site/application vulnerability scanners (confirmed with Arachni and Nessus).
@javiercn are you saying this shouldn't occur on the new SPA proxy stuff in .NET 6.0? (we haven't migrated yet, so I can't confirm)
I ran into this yesterday with an App we were adjusting from the new .Net Core/Angular templates in VS2022 to the older non SPA Proxy approach used in .Net Core 3/Angular. Turns out the angular.json was generating its files in ClientApp/dist while the .csproj file was expecting wwwroot.
In .csproj file, I changed this:
<RelativePath>wwwroot\%(RecursiveDir)%(FileName)%(Extension)</RelativePath>
to this:
<RelativePath>%(DistFiles.Identity)</RelativePath>
This is because our angular.json has, outputPath: dist
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"progress": false,
"outputPath": "dist",
"index": "src/index.html",
Thanks for contacting us.
We're moving this issue to the .NET 9 Planning
milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.
I'm running into this issue with an Angular 15 SPA served from a .NET 7 API. I'm having a difficult time reproducing the issue, but see this error in the API logs.
Commenting to indicate this still appears to be a relevant issue.
@kmjungersen please file a separate ticket through the Visual Studio report a problem dialog.
The issue you are describing is unrelated to the original issue described here.
This issue is related to the SpaExtensions package, we recommend migrating to use SpaProxy for development and UseStaticFiles
directly as the new templates do.
Describe the bug
I have a simple ASP Net core 5 application with Angular ( the template was generated with Microsoft Visual Studio Professional 2019 Version 16.8.3 )
In the development environment if I try to do a POST operation to a wrong path I'm getting 404, but in production I'm getting 500 with the exception System.InvalidOperationException: The SPA default page middleware could not return the default page '/index.html'
This behavior is bothering me because I would prefer 404 instead 500. My application is hosted in Azure and from time to time I see many requests like: POST /Index.html, OPTIONS /index.html, DEBUG /index.html.. and many other weird request methods. I don't know the source of these request, seems to be an automated tool, but this is generating a lot of logs with 500 code.
My temporary solution is to put a custom middleware just before app.UseSpa(..), but I believe this is a bug in ASP Net core, and the correct behavior is to return 404, as it is working in development environment. Appreciate if you can give me some advise on my implementation that tries to avoid this error.
To Reproduce
Exceptions (if any)
System.InvalidOperationException: The SPA default page middleware could not return the default page '/index.html' because it was not found, and no other middleware handled the request. Your application is running in Production mode, so make sure it has been published, or that you have built your SPA manually. Alternatively you may wish to switch to the Development environment.
at Microsoft.AspNetCore.SpaServices.SpaDefaultPageMiddleware.<>cDisplayClass0_0.b1(HttpContext context, Func`1 next)
at Microsoft.AspNetCore.Builder.UseExtensions.<>cDisplayClass0_1. 1(HttpContext context)
at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Builder.UseExtensions.<>cDisplayClass0_2.0(HttpContext context, Func
1 next) at Microsoft.AspNetCore.Builder.UseExtensions.<>c__DisplayClass0_1.<Use>b__1(HttpContext context) at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.HttpsPolicy.HttpsRedirectionMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.HttpsPolicy.HstsMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.Invoke(HttpContext context) --- End of stack trace from previous location --- at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.HandleException(HttpContext context, ExceptionDispatchInfo edi) at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT
1.ProcessRequestAsync() The thread 0x7a20 has exited with code 0 (0x0).Further technical details
.NET SDK (reflecting any global.json): Version: 5.0.101 Commit: d05174dc5a
Runtime Environment: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.101\
Host (useful for support): Version: 5.0.1 Commit: b02e13abab
.NET SDKs installed: 3.0.101 [C:\Program Files\dotnet\sdk] 3.1.100 [C:\Program Files\dotnet\sdk] 5.0.101 [C:\Program Files\dotnet\sdk]
.NET runtimes installed: Microsoft.AspNetCore.All 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.23 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]