?
Solved

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

Posted on 2013-11-08
5
Medium Priority
?
4,706 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses

777 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