简体   繁体   English

如何在MVC 4.0 ASP.NET中从项目外部访问网络中的文件夹?

[英]How to access folder in network which outside from project in MVC 4.0 ASP.NET?

One of my folder is reside in local network or local machine for upload and display attachments. 我的文件夹之一位于本地网络或本地计算机中,用于上传和显示附件。 I can not manage (upload or display) this in MVC 4.0, ASP.NET. 我无法在MVC 4.0,ASP.NET中管理(上传或显示)此文件。 For that I wrote path in appsetting of web.config. 为此,我在web.config的appsetting中编写了路径。 Please guide me how to manage it. 请指导我如何进行管理。

Simply having the path recorded and used does not mean that the application has the permissions to access it. 仅记录和使用路径并不意味着该应用程序有权访问它。

You need to ensure that the account that the web application runs under has the permissions to access this folder (the account details will be in the properties of the web server application pool that is setup for the site). 您需要确保运行该Web应用程序的帐户具有访问此文件夹的权限(该帐户的详细信息将在为站点设置的Web服务器应用程序池的属性中)。

try to: 尝试:

  1. create a Site mapped on your attachments folder 创建一个映射到您的附件文件夹的网站
  2. In your project, add two AppSettings: AttachmentAbsoluteUrl, AttachmentFullname 在您的项目中,添加两个AppSettings:AttachmentAbsoluteUrl,AttachmentFullname

When you have to download an attachment, you can use the Url defined in the AttachmentAbsoluteUrl AppSettings Key, when you have to upload/delete/add, use the AttachmentFullname key. 当您必须下载附件时,可以使用在AttachmentAbsoluteUrl AppSettings项中定义的Url;当您必须上载/删除/添加时,请使用AttachmentFullname项。

In this way you can manage both development and production environments, using different AppSettings values. 这样,您可以使用不同的AppSettings值来管理开发和生产环境。

For example, in my local computer, I have the Attachments folder in the same directory of the project, in production server, I have a different folder outside the Site directory. 例如,在我的本地计算机中,我在项目的同一目录中有“附件”文件夹,在生产服务器中,我在“站点”目录之外有一个不同的文件夹。

You have to check if the Identity of the Application Pool used by your Web application have the rights to modify the contents of the Attachments folder. 您必须检查Web应用程序使用的应用程序池的标识是否有权修改Attachments文件夹的内容。

I hope this can help you 希望对您有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM