How to upload files from ASP.NET to another web application

I have a scenario where I need to download a file from one web application and use it in another. My setup is as follows.

  • One server with two web applications in IIS is ASP.NET
  • One of the applications is used to control another + a bunch of more files
  • I need to download a file from this admin application, save the path to the database via DAL, and then access the file from another web application that would provide the file for download
  • I store files on disk, only path in DB

So where and how can I upload a file so that it can be accessed from both web applications? Should I use the service or is there some other way?
Here are some related questions that I found, but I don’t think they cover my specific scenario:
How to handle uploading files to a dedicated image server? How to upload a file to WCF service?

+4
source share
4 answers

Since both applications are on the same server, this should be simple:

  • Save the downloaded file somewhere to the server.
  • Create a virtual directory in any application that needs files pointing to the physical path.
  • Saving virtual path in db for flexibility
+4
source

You can configure a new virtual directory in each application that points to the same folder on your server where you uploaded the files. Suppose you created a new folder on your c: "uploads" drive, that is, c: \ uploads. Then, in IIS, configure a new virtual directory called "uploads", which points to c: \ uploads for each web application. This should give both sites access to files.

+2
source

May I ask why you do not store the file in the database? This would simplify the transfer.

0
source

Assuming that the path to the file that you put in the database is accessible from a web application other than admin (no matter how it sounds), the file just has to go somewhere that both applications have access rights to. Only the administrator should have write access.

You can configure which user account the IIS website will launch under the website properties> Directory Security in the IIS Management Console. Then just set the appropriate permissions for the directory.

0
source

Source: https://habr.com/ru/post/1277287/


All Articles