【发布时间】:2023-03-18 00:31:02
【问题描述】:
我有以下 ASP.NET Core 项目结构:
.
├── Controllers
├── Dockerfile
├── Models
├── Program.cs
├── Properties
├── README.md
├── Services
├── Startup.cs
├── Views
├── appsettings.json
├── bundleconfig.json
├── project.json
├── web.config
└── wwwroot
在wwwroot 内部,我使用Aurelia cli 建立了一个Aurelia 项目。结构如下:
.
├── aurelia-app
├── css
├── images
├── js
└── temp.html
我的aurelia-app 有我想要服务的index.html 文件(当我浏览到localhost:5000 时,如果它在wwwroot 中,则以类似的方式)
这是我的Startup.cs configure() 方法的样子:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseFileServer(new FileServerOptions
{
EnableDefaultFiles = true,
EnableDirectoryBrowsing = true,
});
app.UseMvc();
}
我应该改变什么,以便在加载基本 url 时,它会在 wwwroot/aurelia-app 目录中查找 index.html 文件?
【问题讨论】:
-
是的,我已经尝试使用
PhysicalFileProvider解决方案,但我收到错误PhysicalFileProvider not found,我该如何添加? -
我正在使用VSCode,所以不知道如何在没有
nuget的情况下添加外部依赖。 -
使用 Microsoft.Extensions.FileProviders 添加;
-
谢谢,解决了这个问题。这听起来很傻,但我在
Path、Directory和PathString对象上也遇到了错误。我应该添加什么来解决这个问题?我对 aspnet core 比较陌生。
标签: c# asp.net-mvc asp.net-core aurelia