简体   繁体   中英

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. For that I wrote path in appsetting of web.config. 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).

try to:

  1. create a Site mapped on your attachments folder
  2. In your project, add two 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.

In this way you can manage both development and production environments, using different AppSettings values.

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.

I hope this can help you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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