2016-01-26 112 views
0

我已经使用dnxcore50示例了在我的VPS(Debian 8)上的docker容器中运行的asp.net 5应用程序。应用程序仅包含静态文件(html,css,js)。在运行docker和VPS的本地VM上都有不在wwwroot目录中的任何文件,例如。/styles /,/ components /,/ scripts /无法访问。请求此文件的状态为200,但服务器不发回任何数据。无法访问wwwroot子目录中的文件

这里是我的配置方法:

 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"] 

这里是ls -l命令输出从VPS我的wwwroot目录

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 

而且例如。 from /样式:

-rwxr-xr-x 1 root root 14976 Jan 10 20:28 Site.css 
+0

您应该删除'app.Run(async(context)=> {});',因为这会导致200个未处理请求的响应。没有它将会发送一个默认的404。 – Tratcher

+0

谢谢。现在它发送404.但仍然不是我想要的:) – Paulie

+0

你应该删除app.Run(async(context)=> {}); 404是你的情况下正确的错误代码。确保你的网址是正确的。网址路径区分大小写 –

回答

0

请注意,StaticFile路径在Linux上区分大小写。

+0

我已将它全部写成小写字母,并且它可以工作:)谢谢。 – Paulie

相关问题