Is it possible to link a file from shared drive on public facing website? - iis-7

I have searched for the answer to this question, and have found some similar results, but most seem to be interested in linking a file on an internal website (such as this one: An URL to a Windows shared folder). I am hoping to find a way to link a file on a public facing site.
On my windows server, I have several drives - for the ease of this, let's call them C:, D:, and E:
C: is, of course, the OS.
I have a file share for internal users (those on the same network) on E:. I have the file share location shared internally as \server\data.
I have a public facing website (through IIS) on D:. Let's say the website is located at D:\Website, with the default page being D:\Website\index.html.
Is it possible to create a link on the website that points to files on the E: drive? Like file://server/data/file.txt? Or would it be easier to move the website to the same directory as the file share?

it is possible , but \\server (Windows UNC port 445) is a port that was abused and is blocked by many ISP's for almost a decade now.
Your "public" most likely will not have access
file:/// will not work either , as to the user, that means the persons local machine
what you can do is create a virtual directory to your drive or network share in IIS and make sure in iis (optionally can you can enable use directory browsing)
ftp:// is also a possibility as well and what i think you should look into

Related

ASP.Net Accessing Server Filesystem

I am having trouble accessing information on the server my website it on. As the website was originally programmed with VB.Net, I cannot change the language without having to completely reboot the website. The way the website and server are configured, I can only use ASP.Net and VB.Net.
I am needing to add a section where they can create folders, edit folder names, and upload pictures and text documents on the server through the public website. I tried using parts of the FileIO, Server, and Http that should have worked, but none of them did. Most of my research is about local files and text documents.
I have not been able to find any information that works. Can someone help me? Thank you.
Firstly, creating a virtual directory in ISS mapped to somewhere on your disk would be a good start. This way you have a separate folder for user data in a folder with write access (make sure IIS has write access to the folder!), and the folder is not affected by website deployments.
Secondly, you might need to resolve absolute path for most of the System.IO.File calls. See How to convert a relative path to an absolute path in a Windows application?, just you will need to convert this code to VB.

How can I link a WebDAV URL within windows explorer (w7) to a regular folder instead of using a network link (standard)?

Normally a WebDAV URL shows up as a network link within the table of root directory trees (c:/; d:/). I would like the WebDAV URL to be accessed from a regular folder e.g. c:/user/download.
How do I link the URL manually and/ or using the msdn WebDAV API for script configuration?
Thanks!
I dont know of any windows clients that can mount a drive into a local file system. A couple of options
Mount a drive like normal and then use a linked folder (ok, not a great option)
Use a file sync client to sync a local folder to the webdav server
There are a handful of sync clients around. Here's a new one that looks nice, although i havent used it - https://www.syncany.org/

/tmp file name collisions when hosting hundreds of small Drupal sites

We host a few hundred small Drupal 6 & 7 websites on a single Debian virtual machine. Each of these sites has it's own Drupal code base and database.
When we had each site using /tmp as the "Temporary files" folder in Drupal, we would occasionally have file name collisions across sites.
Is making a /tmp/site_name folder for each site our only option to stop these file collisions?
Multisite doesn't make sense when you do multiple sites for many clients. They are on different boxes sometimes (their hosting), and it just is cleaner to have version control for each site/drupal folder vs trying to put 200 sites in 1 svn project for the 200 clients. For us, we had a demo server for each of these sites. and standalone folders mapped to demo1.test.com, demo2.test.com... I got some issues when duplicating a site to another test subdomain server. The error had some /tmp message in it and some other complaints and Denied Access to my site. The error seemed to go away after refreshing the site. but not sure if visiting many sites at a time will cause issue to popup again... Maybe in the long run it makes sense to have a special tmp folder for each site. maybe like you suggested /tmp/site_name or ../tmp if can use file structure like: /var/www/vhosts/site1/public (for drupal sites) /var/www/vhosts/site1/tmp (for tmp dir)... not sure what perms to give it though.
try to install Drush on your virtual server, as it will help you a lot
Drupal provide multisite concept where you can use same module for all sites.
https://drupal.org/documentation/install/multi-site

Upload file to virtual directory

I have a web application with a page. The page has a functionality to upload a file.
I have deployed the application on two different servers in IIS7. Both these hosting have a virtual directory pointing to the same physical directory.
Here I am unable to save the posted file in the virtual directory using Server.MapPath.
Is there any sophisticated technique to handle such situation to achieve this functionality?
Well I'd suggest you 2 scenarios:
Share a folder/resource beetween those servers (assuming that
those servers are in the same LAN), then create app key in the
web.config and this key will contain the path of your shared
resource something like //Server/Folder, use this value instead of server.mappath at the time you
save the file in the server
If you have a load balancer share a folder of your main node and
then use the that path in your secondary node something like
//server/folder that route will save the image in the main node, then
set up a replication rule from your main node and the secondary the
configuration of this rule could vary depending on your needs it
could be an update to the seconday node every 5 minutes for example.
you may create a virtual directory but the purpose for this will be only for displaying the images.
that worked for for me some time ago, it's not a fancy solution but it does the job.

Deleting a directory results in application restart

I have an application with 2 directories (books and export).
If we create a book or a page of a book in the application a directory is added with the id of the page (this is for uploading resources).
If we delete a page, the page (and it's directory) is removed from the database and the filesystem.
However this resulted in a session loss (even an application restart). I've looked up some thing on google and found the following link.
It seems to be a problem in ASP.NET 2.0 (and 3.5).
We are now thinking about writing a service that will clean up the directories at night.
But there has got to be another solution for this no?
Oh and putting the directory outside the virtual directory is not an option.
Try disabling the monitoring of File System. This will prevent your session alive.
This article may be usefull for you.
Oh and putting the directory outside
the virtual directory is not an
option.
Putting the directory outside the virtual directory is the only solution I found (so far). What you can do, is to create a link (junction) in the file system so that the directory appears to be inside the virtual directory, e.g:
Our web site (virtual directory) is located at C:\projectX\website
the data directory (where we create/delete files and folders) is located at C:\projectX\data
then we create a link which makes the data folder available as C:\projectX\website\data
The link is created using the program Linkd.exe (available in the windows resource kit), with the following command:
linkd c:\projectX\website\data c:\projectX\data
Now c:\projectX\website\data is a link/junction which points to the real data directory. You can work with the link as if it were a physical directory.
E.g. in your web site you can access it using this code:
Server.MapPath("~/data")
And you can also used the windows file explorer and browse to C:\projectX\website\data. It appears just like a real directory.
There seems to be a supported hotfix which achieves the same as the article Sachin mentioned (turn off the file change notifications in a web site).
Check this article in the microsoft KB for more information.
But since you mentioned in a comment, that you do not have access to the server, I guess this will also not help in your case.
For storing data files that are frequently updated, created and deleted you need to use App_Data folder in the root of the web site. MSDN for App_Data folder states:
Contains application data files
including MDF files, XML files, as
well as other data store files. The
App_Data folder is used by ASP.NET 2.0
to store an application's local
database, which can be used for
maintaining membership and role
information.
Also check Q&A section for App_Data folder usage: App_Data folder question
I had the same problem. The solution is to externalize the session handling by using the ASP.Net State service. The only draw back is that every object you place in the session needs to be serializable, as it is transferred to the state service and back.
I currently do not have the possibility to provide further links, but google will help you, now that you know what to search for.

Resources