部署项目时无法访问"wwwroot"中的文件 [英] Can't reach file in 'wwwroot' when project is deployed

查看:58
本文介绍了部署项目时无法访问"wwwroot"中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Visual Studio中使用IIS Express进行调试并尝试访问/wwwroot中的文件时,路径='wwwroot/fileName'没有任何问题.

when I work in debug with IIS Express in visual studio and try to reach a file in /wwwroot, I don't have any problem with the path = 'wwwroot/fileName'.

但是当我将网站部署到IIS Express服务器中时,我再也无法访问该文件,并且由于该文件不存在而收到错误消息.

But when I deploy my website into IIS Express server, I can't reach the file anymore and I get error because the file doesn't exist.

我做错什么了吗?部署WebSite时路径是否不同?

Did I make something wrong ? Did the path is not the same when WebSite is deploy ?

PS:文件的扩展名为'.xlsx'

PS : The file is '.xlsx' extension

推荐答案

很有可能没有部署文件.假设您使用的是Visual Studio,请尝试以下操作:

Most likely the file is not being deployed. Assuming you're using Visual Studio, try this:

  1. 在解决方案资源管理器中,右键单击您的.xlsx文件,然后选择属性".
  2. 构建操作中,确保选择了内容.
  3. 复制到输出目录中,确保您具有始终复制"或如果更新则复制".只需确保未选择请勿复制"即可.
  1. In Solution Explorer, right click your .xlsx file and choose Properties.
  2. In Build Action, make sure Content is selected.
  3. In Copy to Output Directory, make sure you have either Copy Always or Copy if Newer. Just make sure Do Not Copy is not selected.

我的猜测是,您会发现内容"字段有问题.再次部署,您应该一切顺利.

My guess is you will find something wrong with that Content field. Deploy again and you should be good to go.

这篇关于部署项目时无法访问"wwwroot"中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆