我使用dnxcore50对我的VPS(Debian 8)上的docker容器中运行的asp.net 5 app进行了示例。应用程序仅包含静态文件(html,css,js)。在我的本地VM上运行docker和在VPS上的任何文件都不在wwwroot目录中,例如。 / styles /,/ components /,/ scripts /无法访问。对此文件的请求状态为200,但服务器不会发回任何数据。
这是我的配置方法:
public void Configure(IApplicationBuilder app)
{
app.UseIISPlatformHandler();
app.UseStaticFiles();
app.Run(async (context) =>
{
});
}
Project.json文件:
{
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://0.0.0.0:5000"
},
"frameworks": {
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
和dockerfile
FROM microsoft/aspnet:1.0.0-rc1-update1-coreclr
COPY . /app
WORKDIR /app/approot/src/WebApplication5
RUN ["dnu", "restore"]
EXPOSE 5000
ENTRYPOINT ["dnx", "web"]
这是来自VPS上我的wwwroot目录的ls -l输出
drwxr-xr-x 7 root root 4096 Jan 26 18:07 Components
drwxr-xr-x 2 root root 4096 Jan 26 18:07 Images
drwxr-xr-x 2 root root 4096 Jan 26 18:07 Scripts
drwxr-xr-x 2 root root 4096 Jan 26 18:07 Styles
-rwxr-xr-x 1 root root 9582 Jan 10 20:31 cart.html
-rwxr-xr-x 1 root root 13569 Jan 10 20:29 category.html
-rwxr-xr-x 1 root root 10467 Jan 10 20:30 index.html
-rwxr-xr-x 1 root root 6282 Jan 15 17:50 login.html
-rwxr-xr-x 1 root root 13273 Jan 3 17:39 rowsgrid.html
-rwxr-xr-x 1 root root 4611 Jan 10 20:31 signin.html
-rwxr-xr-x 1 root root 396 Jan 26 18:07 web.config
对于例如。来自/样式:
-rwxr-xr-x 1 root root 14976 Jan 10 20:28 Site.css
答案 0 :(得分:0)
请注意,StaticFile路径在linux上区分大小写。