提问人:Anibal Yeh 提问时间:11/15/2023 更新时间:11/15/2023 访问量:44
找不到 Razor 应用程序 404 页面
Razor application 404 page not found
问:
当我使用 .Net 5 Razor 启动应用程序时
dotnet BaGet.dll
它总是说找不到 404 页面。
但是,如果我 dotnet 运行它或执行 BaGet.exe 文件,一切都很好。
所有这些静态文件都分离在另一个项目中
https://github.com/loic-sharma/BaGet
var path = Path.Combine(_env.ContentRootPath, "..", "BaGet.Web");
ContentRootPath 是正确的
var provider = new PhysicalFileProvider(Path.GetFullPath(path))
是否经过验证?
如何正确使用“dotnet BaGet.dll”?
答:
0赞
Jason Pan
11/15/2023
#1
这是预期行为。wwwroot 文件夹下没有任何静态文件。
最后,我在这里找到了所有文件。
然后将它们复制到项目内的文件夹中,如下所示。wwwroot
并在 .csproj 文件中添加以下设置,其中将在生成项目时包含静态文件。
<ItemGroup>
<None Include="wwwroot\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
然后我们将在 .wwwroot
YOUR_DRIVER:\BaGet-main\BaGet-main\src\BaGet\bin\Debug\netcoreapp3.1
好了,现在您可以运行命令来启动项目了。
0赞
Anibal Yeh
11/23/2023
#2
最终的答案是发布应用程序和 UseStaticFiles 有效。
评论