0

My ASP.NET-application is generating static files that can then be accessed by the user directly, e.g. https://example.com/usercontent/xyz.pdf

Currently, this is achieved by writing the generated files directly into the phyiscal directory inside the web-application (like D:\Path\To\Webapp\usercontent\xyz.pdf) and let the user access them via the URL. Unfortunately, the directory on the drive is deleted during each deployment of the application. Is it possible to remap URLs containing this folder to another physical location by using the web.config only?

This way, the deployment would not clean it each time it runs.

Andreas
  • 1,997
  • 21
  • 35
  • A virtual directory map in IIS would solve this or take a look at this question http://stackoverflow.com/questions/4410067/iis-url-rewrite-and-web-config – Steve Apr 27 '17 at 14:58

1 Answers1

1

Maybe you cannot do what you are asking for but:

ALTERNATIVE 1: You could exclude USERCONTENT directory from deploy process. If you use MSBUILD for deploy, take a look here: How to exclude folders from publish/deployment of Visual Studio 2013 Web Application

ALTERNATIVE 2: In this kind of situations i use S3 Bucket (or a similar cloud service) as static file container.

ALTERNATIVE 3: Run another site in IIS just for static files and access it programmatically via FTP from site 1 when you need to push a new file.

Community
  • 1
  • 1
Michele P
  • 176
  • 4