Solved

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

Posted on 2013-11-08
5
4,087 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 75

Expert Comment

by:käµfm³d 👽
ID: 39635368
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
ID: 39639788
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 75

Expert Comment

by:käµfm³d 👽
ID: 39640014
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
ID: 39640081
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
ID: 39653041
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 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