【发布时间】:2020-12-24 13:54:35
【问题描述】:
我有一个在 Visual Studio for Mac 上构建的相当标准的 .net 核心 MVC 应用程序。我已向 Azure 应用服务发布了可能类似的项目。
我现在正尝试将此 MVC 应用程序发布到 Google App Engine。它发布并运行,但浏览器无法访问 wwwroot 文件夹中的任何静态内容 - 所有文件路径都返回 404。
我已确认正在将文件复制到服务器。通过 SSH 我运行 sudo docker exec -it gaeapp /bin/bash
在我登陆的目录中,我看到以下内容:
DnsClient.dll
Dockerfile
... (project dlls)
app.yaml
appsettings.json
bundleconfig.json
publish
runtimes
source-context.json
web.config
在发布目录中我看到:
DnsClient.dll
... (project dlls)
app.yaml
appsettings.json
bundleconfig.json
runtimes
web.config
wwwroot
wwwroot 包含我期望的所有文件。我尝试将文件从 wwwroot 复制到树的各个级别,但仍然无法访问这些文件。
这是我的 app.yaml 以防万一:
runtime: aspnetcore
env: flex
# This sample incurs costs to run on the App Engine flexible environment.
# The settings below are to reduce costs during testing and are not appropriate
# for production use. For more information, see:
# https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
env_variables:
# The __ in My__Greeting will be translated to a : by ASP.NET.
My__Greeting: Hello AppEngine!root@c2d2b26894e2:/app#
有什么想法可以解决这个问题吗?
更多信息
如果我的项目出现问题,我从 VS 模板创建了一个新的 MVC 项目并发布了它。同样的问题,如下面的截图所示。尝试使用默认模板,并按照答案中的建议添加了app.UseDefaultFiles();。
所以,我认为问题出在 Google 或部署中...
【问题讨论】:
标签: asp.net-mvc asp.net-core google-app-engine google-cloud-platform