Solved

How do I store files outside of C# ASP.NET application root folder in IIS.

Posted on 2013-11-08
5
3,848 Views
Last Modified: 2013-11-16
"../" style parent paths do not work
"~/" tildas  do not work as they only go to the app root also

It is important to not this WebApp is stored in a same named subfolder shown as bold.  
It is an MVC ASP.NET C# 4.0 database editing APP.
eg c:\inetpub\wwwroot\projectname\projectname

In the Root Folder I have a standard ASP.NET web application in Italics.
I need some advice or code on how to escape the application in the subfolder to store files in the true root folder.

My IIS version is 8 on an x64 machine.

Does this request have anything to do with "Double Escaping" that can be overridden in the request filtering? or is that unrelated.
I am interested in a web.config based solution if at all possible, in an attempt to overcome ever changing IIS security changes.
0
Comment
Question by:XGIS
  • 3
  • 2
5 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
The only way I know to accomplish this is to make a symbolic link to the parent folder from within the child folder. Then it appears as though the parent is a child of the child, but on the physical file system it is not. You can use the mklink utility for this.
0
 
LVL 7

Accepted Solution

by:
XGIS earned 0 total points
Comment Utility
To overcome the issue of uploading ABOVE the APPLICATION ROOT Folder is very simple if you use Virtual Directories in IIS.
This example is created based on the ANM10 Generated Website being Nested in another website.
The reason for this is it gives me somewhere to put folders and files so I do not risk accidentally generating over my folders and files.
It also helps me to maintain a single folder in WWWROOT for all Website related tasks.
It is also a good place to store sensitive files such as the AGX which should NOT be located in the published website folder.

Related Posts:
Custom Image Upload Folders - Row_Inserting Event - viewtopic.php?f=45&t=33634
Increase Image - File Uploads to 100Mb - viewtopic.php?f=45&t=33638

The Goals:
1. Store Files in Folders Above the Application Root Folder; e.g. C:\inetpub\wwwroot\MainWebsite\YourCustomVDUploadFolder\
2. Manage Files elsewhere using a Virtual Directory in IIS here; e.g. C:\inetpub\wwwroot\MainWebsite\ANM10WebsiteAppRoot\
3. Enable complete site regeneration without risk of losing existing folder based data.
4. Cleaner, safer and faster delivery of presentation application eg ASP.NET
5. Static safe folder for server scheduled backups of data eg using BAT files etc

All code will be directed at the Virtual directory but all files will actually live in the physical folder above the application root.
There is need to even create the folder. If you do and you always regenerate using "Clear All" you would have to manually create it each time or code it to autogenerate.

1. Windows Explorer: Create this folder; e.g. C:\inetpub\wwwroot\MainWebsite\YourCustomVDUploadFolder"
2. IIS: Click on this folder e.g. C:\inetpub\wwwroot\MainWebsite\ANM10WebsiteAppRoot\
3. Right click to create the Virtual Directory folder e.g. "YourCustomVDUploadFolder" which simply points to the physical folder that in this case is one folder above the Application Root.

This is NOT limited to this structure or location, but the example was based only on my immediate needs.
Maybe you have an existing or separate website where the files need to be made available e.g D or E etc.
This is NOT limited to custom uploads referred to in the posts above. The same should be possible for standard ANM10 file upload to folder based projects.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
I try to minimise 3rd party dependencies and utilise existing infrastructure to avert breakdowns
mklink is a utility provided by Microsoft, and it comes already installed in Windows Server, so I wouldn't consider it a "3rd party" solution. But if you've got a working solution, then that is what counts  = )
0
 
LVL 7

Author Comment

by:XGIS
Comment Utility
Hello kaufmed.. apologies for my bad choice of words... it should have been something like code dependencies.  Again thankyou for your time and i welcome your suggestions in the future.
0
 
LVL 7

Author Closing Comment

by:XGIS
Comment Utility
Hello Kaufmed.. thankyou for your time..while your suggestion may have been suitable in some programming scenarios it was difficult to integrate as my IDE is restricted in what it can and cannot use. Similarly I try to minimise 3rd party dependencies and utilise existing infrastructure to avert breakdowns.  IIS Virtual directories were all that was required to overcome application limitations and IIS security issues.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now