For SPA projects, usually the front-end project is Angular/React/Vue
, and the back-end project is ASP.NET Core API
.
Therefore, in the ASP.NET Core API, you need to use app.UseSpa
or UseStaticFiles
to allow static resource files to be read, and then the front-end project of the SPA needs to be included in the compilation process. This ensures that the index.html
file can be found using useFallBack
as an entry.
Sample settings
<ItemGroup>
<!-- Don't publish the SPA source files, but do show them in the project files list -->
<Content Remove="$(SpaRoot)**" />
<None Remove="$(SpaRoot)**" />
<None Include="$(SpaRoot)**" Exclude="$(SpaRoot)node_modules\**" />
<Content Include="ClientApp\dist\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Jason